podman使用

1.podman使用

使用 Podman 非常的简单,Podman 的指令跟 Docker 大多数都是相同的。下面我们来看几个常用的例子:

运行一个容器

[root@localhost ~]# podman run -d --name httpd docker.io/library/httpd
Trying to pull docker.io/library/httpd:latest...
Getting image source signatures
Copying blob 1efc276f4ff9 done  
Copying blob aed046121ed8 done  
Copying blob 80e368ef21fc done  
Copying blob 80cb79a80bbe done  
Copying blob 4340e7be3d7f done  
Copying config f2a976f932 done  
Writing manifest to image destination
Storing signatures
f387d2ae8a3fc19696cd5c1760a8be53d9e286096b3b37b560372906c67fc3bf

//查看镜像
[root@localhost ~]# podman  images
REPOSITORY                       TAG         IMAGE ID      CREATED      SIZE
docker.io/library/httpd          latest      f2a976f932ec  13 days ago  149 MB

列出运行的容器

[root@localhost ~]# podman ps
CONTAINER ID  IMAGE                           COMMAND           CREATED         STATUS             PORTS       NAMES
f387d2ae8a3f  docker.io/library/httpd:latest  httpd-foreground  21 minutes ago  Up 21 minutes ago              httpd

注意:如果在ps命令中添加-a,Podman 将显示所有容器。

检查正在运行的容器

您可以“检查”正在运行的容器的元数据和有关其自身的详细信息。我们甚至可以使用 inspect 子命令查看分配给容器的 IP 地址。由于容器以无根模式运行,因此未分配 IP 地址,并且该值将在检查的输出中列为“无”。

[root@localhost ~]# podman inspect -l | grep IPAddress\":
            "IPAddress": "10.88.0.2",
                    "IPAddress": "10.88.0.2",
[root@localhost ~]# curl 10.88.0.2
<html><body><h1>It works!</h1></body></html>

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

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

选项
  --latest    #最近的
  
[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 08:12:25.828458 2022] [mpm_event:notice] [pid 1:tid 140451088780608] AH00489: Apache/2.4.54 (Unix) configured -- resuming normal operations
[Mon Aug 15 08:12:25.828830 2022] [core:notice] [pid 1:tid 140451088780608] AH00094: Command line: 'httpd -D FOREGROUND'
10.88.0.1 - - [15/Aug/2022:08:38:07 +0000] "GET / HTTP/1.1" 200 45

查看一个运行容器中的进程资源使用情况,可以使用top观察容器中的 nginx pid

语法:
  podman top <container_id>
  
[root@localhost ~]# podman  top httpd 
USER        PID         PPID        %CPU   
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值