podman的用法

本文介绍了Podman的使用方法,包括检查运行的容器、查看容器日志和资源使用情况。强调了非root用户如何配置Podman,如安装slirp4netns和fuse-overlayfs,设置subuid和subgid。还详细讨论了容器卷的使用,解释了普通用户映射端口的限制及解决方案。
摘要由CSDN通过智能技术生成

podman的用法


使用podman

检查正在运行的容器
我们甚至可以使用 inspect 子命令查看分配给容器的 IP 地址。由于容器以无根模式运行,因此未分配 IP 地址,并且该值将在检查的输出中列为“无”。

[root@localhost ~]# podman inspect -l |grep -i addr
            "IPAddress": "10.88.0.2",
            "GlobalIPv6Address": "",
            "MacAddress": "26:d8:f7:9f:bb:a4",
            "LinkLocalIPv6Address": "",
                    "IPAddress": "10.88.0.2",
                    "GlobalIPv6Address": "",
                    "MacAddress": "26:d8:f7:9f:bb:a4",
[root@localhost ~]# curl 10.88.0.2
<html><body><h1>It works!</h1></body></html>
[root@localhost ~]#

注意:-l 是最新容器的便利参数。您还可以使用容器的 ID 代替 -l。

查看一个运行中容器的日志

[root@localhost ~]# podman logs --latest
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.88.0.2. Set the 'ServerName' directive globally to suppress this message
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.88.0.2. Set the 'ServerName' directive globally to suppress this message
[Mon Aug 15 06:13:01.998854 2022] [mpm_event:notice] [pid 1:tid 140504491691328] AH00489: Apache/2.4.52 (Unix) configured -- resuming normal operations
[Mon Aug 15 06:13:02.004264 2022] [core:notice] [pid 1:tid 140504491691328] AH00094: Command line: 'httpd -D FOREGROUND'
10.88.0.1 - - [15/Aug/2022:06:14:34 +0000] "GET / HTTP/1.1" 200 45
[root@localhost ~]#

查看一个运行容器中的进程资源使用情况

[root@localhost ~]# podman ps
CONTAINER ID  IMAGE                           COMMAND           CREATED        STATUS            PORTS       NAMES
975e90c05c22  docker.io/library/httpd:latest  httpd-foreground  5 minutes ago  Up 5 minutes ago              axi
[root@localhost ~]#
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值