podman(续)

podman


使用 Podman

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

运行一个容器

[root@localhost ~]# podman run -d --name web1 httpd
Resolving "httpd" using unqualified-search registries (/etc/containers/registrie
Trying to pull docker.io/library/httpd:latest...
Getting image source signatures
Copying blob 1efc276f4ff9 done  
Copying blob 80cb79a80bbe done  
Copying blob 4340e7be3d7f done  
Copying blob aed046121ed8 done  
Copying blob 80e368ef21fc done  
Copying config f2a976f932 done  
Writing manifest to image destination
Storing signatures
8e87d33fedaef42db358db3d2152aaa9de16cd7e51016cef48a0e01d9fd730db

//查看镜像

[root@localhost ~]# podman images
REPOSITORY                    TAG         IMAGE ID      CREATED      SIZE
docker.io/library/httpd       latest      f2a976f932ec  13 days ago  149 MB
docker.io/wyn0116/busybox123  v1          7a80323521cc  2 weeks ago  1.47 MB
docker.io/library/busybox     latest      7a80323521cc  2 weeks ago  1.47 MB

列出运行的容器

[root@localhost ~]# podman ps
CONTAINER ID  IMAGE                             COMMAND           CREATED        STATUS            PORTS       NAMES
6229a94b2a49  docker.io/library/busybox:latest  sh                22 hours ago   Up 22 hours ago               yyz
8e87d33fedae  docker.io/library/httpd:latest    httpd-foreground  2 minutes ago  Up 2 minutes ago              web1

[root@localhost ~]# podman ps -a
CONTAINER ID  IMAGE                             COMMAND           CREATED        STATUS            PORTS       NAMES
6229a94b2a49  docker.io/library/busybox:latest  sh                22 hours ago   Up 22 hours ago               yyz
8e87d33fedae  docker.io/library/httpd:latest    httpd-foreground  3 minutes ago  Up 3 minutes ago              web1

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

检查正在运行的容器

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

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

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

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

选项
–latest #最近的

[root@localhost ~]# podman logs -l
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.88.0.5. 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.5. Set the 'ServerName' directive globally to suppress this message
[Mon Aug 15 07:35:13.377854 2022] [mpm_event:notice] [pid 1:tid 139753627139392] AH00489: Apache/2.4.54 (Unix) configured -- resuming normal operations
[Mon Aug 15 07:35:13.378237 2022] [core:notice] [pid 1:tid 139753627139392] AH00094: Command line: 'httpd -D FOREGROUND'
10.88.0.1 - - [15/Aug/2022:07:41:04 +0000] "GET / HTTP/1.1" 200 45

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

语法:
podman top <container_id>

[root@localhost ~]# podman top 8e87d33fedae
USER        PID         PPID        %CPU        ELAPSED           TTY         TIME        COMMAND
root        1           0           0.000       20m41.189593645s  ?           0s          httpd -DFOREGROUND 
www-data    7           1           0.000       20m40.189786642s  ?           0s          httpd -DFOREGROUND 
www-data    8           1           0.000       20m40.189931624s  ?           0s          httpd -DFOREGROUND 
www-data    9           1           0.000       20m40.190205558s  ?           0s          httpd -DFOREGROUND 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值