Clarify inspect example in basic setup tutorial

Fixes: https://github.com/containers/podman/issues/28762

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
This commit is contained in:
Jan Rodák 2026-05-25 10:58:07 +02:00
parent bd7e8bbab3
commit 2162404eaf
No known key found for this signature in database
GPG key ID: D458A9B20435C2BF
2 changed files with 37 additions and 10 deletions

View file

@ -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 <container_id>
```
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 <container_id>
And you can observe the httpd pid in the container with *top*.
```console
podman top <container_id>
```
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

View file

@ -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 <container_id>
```
示例输出:
```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