From 2162404eaf8a1a2270f1bc3daaa8a7b96aa60802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Rod=C3=A1k?= Date: Mon, 25 May 2026 10:58:07 +0200 Subject: [PATCH] Clarify inspect example in basic setup tutorial MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: https://github.com/containers/podman/issues/28762 Signed-off-by: Jan Rodák --- docs/tutorials/podman_tutorial.md | 22 ++++++++++++++++++---- docs/tutorials/podman_tutorial_cn.md | 25 +++++++++++++++++++------ 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/docs/tutorials/podman_tutorial.md b/docs/tutorials/podman_tutorial.md index 4db0162073..39e4e5b186 100644 --- a/docs/tutorials/podman_tutorial.md +++ b/docs/tutorials/podman_tutorial.md @@ -36,11 +36,15 @@ podman ps Note: If you add *-a* to the *ps* command, Podman will show all containers. ### Inspecting a running container You can "inspect" a running container for metadata and details about itself. We can even use -the inspect subcommand to see what IP address was assigned to the container. As the container is running in rootless mode, an IP address is not assigned and the value will be listed as "none" in the output from inspect. +the inspect subcommand to see what IP address was assigned to the container. As the container is running in rootless mode, an IP address is often not assigned and the field may be empty. ```console -podman inspect basic_httpd | grep IPAddress\": - "SecondaryIPAddresses": null, - "IPAddress": "", +podman inspect basic_httpd --format 'IP address: {{.NetworkSettings.IPAddress}}' +``` + +Example output (rootless): + +```text +IP address: ``` ### Testing the httpd server @@ -55,6 +59,11 @@ curl http://localhost:8080 You can view the container's logs with Podman as well: ```console podman logs +``` + +Example output: + +```text 10.88.0.1 - - [07/Feb/2018:15:22:11 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.55.1" "-" 10.88.0.1 - - [07/Feb/2018:15:22:30 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.55.1" "-" 10.88.0.1 - - [07/Feb/2018:15:22:30 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.55.1" "-" @@ -66,6 +75,11 @@ podman logs And you can observe the httpd pid in the container with *top*. ```console podman top +``` + +Example output: + +```text UID PID PPID C STIME TTY TIME CMD 0 31873 31863 0 09:21 ? 00:00:00 nginx: master process nginx -g daemon off; 101 31889 31873 0 09:21 ? 00:00:00 nginx: worker process diff --git a/docs/tutorials/podman_tutorial_cn.md b/docs/tutorials/podman_tutorial_cn.md index 6b090e3b9e..7d682fc3a8 100644 --- a/docs/tutorials/podman_tutorial_cn.md +++ b/docs/tutorials/podman_tutorial_cn.md @@ -40,16 +40,19 @@ podman ps ### 查看正在运行的容器 -你可以 "inspect" (查看)一个正在运行的容器的元数据以及其他详细信息。我们甚至可以使用 inspect 的子命令查看分配给容器的 IP 地址。由于容器以非 root 模式运行,没有分配 IP 地址,inspect 的输出会是 " -none" 。 +你可以 "inspect" (查看)一个正在运行的容器的元数据以及其他详细信息。我们甚至可以使用 inspect 的子命令查看分配给容器的 IP 地址。由于容器以非 root 模式运行,通常不会分配 IP 地址,该字段可能为空。 ```console -podman inspect -l | grep IPAddress\": - "SecondaryIPAddresses": null, - "IPAddress": "", +podman inspect basic_httpd --format 'IP address: {{.NetworkSettings.IPAddress}}' ``` -**注意**:*-l* 参数是**最近的容器**的指代,你也可以使用容器的ID 代替 *-l* +示例输出(非 root 模式): + +```text +IP address: +``` + +**注意**:你也可以使用 *-l* 查看**最近的容器**,或使用容器 ID 代替容器名称。 ### 测试httpd服务器 @@ -65,6 +68,11 @@ curl http://localhost:8080 ```console podman logs --latest +``` + +示例输出: + +```text 10.88.0.1 - - [07/Feb/2018:15:22:11 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.55.1" "-" 10.88.0.1 - - [07/Feb/2018:15:22:30 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.55.1" "-" 10.88.0.1 - - [07/Feb/2018:15:22:30 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.55.1" "-" @@ -78,6 +86,11 @@ podman logs --latest ```console podman top +``` + +示例输出: + +```text UID PID PPID C STIME TTY TIME CMD 0 31873 31863 0 09:21 ? 00:00:00 nginx: master process nginx -g daemon off; 101 31889 31873 0 09:21 ? 00:00:00 nginx: worker process