podman

什么是Podman?

Podman 是一个开源的容器运行时项目,可在大多数 Linux 平台上使用。Podman 提供与 Docker 非常相似的功能。正如前面提到的那样,它不需要在你的系统上运行任何守护进程,并且它也可以在没有 root 权限的情况下运行。

Podman 可以管理和运行任何符合 OCI(Open Container Initiative)规范的容器和容器镜像。Podman 提供了一个与 Docker 兼容的命令行前端来管理 Docker 镜像。

Podman 官网地址:https://podman.io/

Podman和Docker的主要区别是什么?

  • dockers在实现CRI的时候,它需要一个守护进程,其次需要以root运行,因此这也带来了安全隐患。
  • podman不需要守护程序,也不需要root用户运行,从逻辑架构上,比docker更加合理。
  • 在docker的运行体系中,需要多个daemon才能调用到OCI的实现RunC。
  • 在容器管理的链路中,Docker Engine的实现就是dockerd
  • daemon,它在linux中需要以root运行,dockerd调用containerd,containerd调用containerd-shim,然后才能调用runC。顾名思义shim起的作用也就是“垫片”,避免父进程退出影响容器的运训
  • podman直接调用OCI,runtime(runC),通过common作为容器进程的管理工具,但不需要dockerd这种以root身份运行的守护进程。
  • 在podman体系中,有个称之为common的守护进程,其运行路径通常是/usr/libexec/podman/conmon,它是各个容器进程的父进程,每个容器各有一个,common的父则通常是1号进程。podman中的common其实相当于docker体系中的containerd-shim。

Podman常用命令

容器

podman run           创建并启动容器
podman start         启动容器
podman ps            查看容器
podman stop          终止容器
podman restart       重启容器
podman attach        进入容器
podman exec          进入容器
podman export        导出容器
podman import        导入容器快照
podman rm            删除容器
podman logs          查看日志

镜像

podman search                检索镜像
podman pull                  获取镜像
podman images                列出镜像
podman image Is              列出镜像
podman rmi                   删除镜像
podman image rm              删除镜像
podman save                  导出镜像
podman load                  导入镜像
podmanfile                   定制镜像(三个)
  podman build             构建镜像
    podman run               运行镜像
    podmanfile               常用指令(四个)
      COPY                 复制文件
        ADD                  高级复制
        CMD                  容器启动命令
        ENV                  环境变量
        EXPOSE               暴露端口

部署 Podman

//安装podman
[root@localhost ~]# dnf -y install podman

拉镜像

[root@localhost ~]# podman pull busybox
Resolved "busybox" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull docker.io/library/busybox:latest...
Getting image source signatures
Copying blob 50783e0dfb64 done  
Copying config 7a80323521 done  
Writing manifest to image destination
Storing signatures
7a80323521ccd4c2b4b423fa6e38e5cea156600f40cd855e464cc52a321a24dd
[root@localhost ~]# podman images
REPOSITORY                 TAG         IMAGE ID      CREATED      SIZE
docker.io/library/busybox  latest      7a80323521cc  13 days ago  1.47 MB

版本8配置加速器

#unqualified-search-registries = ["registry.fedoraproject.org",		"registry.access.redhat.com", "registry.centos.org", "docker.io"]
unqualified-search-registries = ["docker.io"]

[[registry]]
location = "y8k9uk13.mirror.aliyuncs.com"

推送镜像

[root@localhost ~]# podman tag busybox:latest glume007/busybox:1
[root@localhost ~]# podman login docker.io
Username: glume007
Password: 
Login Succeeded!
[root@localhost ~]# podman push glume007/busybox:1 
Getting image source signatures
Copying blob 084326605ab6 skipped: already exists  
Copying config 7a80323521 done  
Writing manifest to image destination
Storing signatures

拉取镜像

[root@congfuwuqi ~]# podman login
Username: glume007
Password: 
Login Succeeded!
[root@congfuwuqi ~]# podman push glume007/busybox:v1 
Getting image source signatures
Copying blob 084326605ab6 skipped: already exists  
Copying config 7a80323521 [---------------] 0.0b / 1.4KiB
Writing manifest to image destination
Storing signatures
[root@congfuwuqi ~]# podman rmi glume007/busybox:v1 
Untagged: localhost/glume007/busybox:v1
[root@congfuwuqi ~]# podman pull glume007/busybox:v1 
Resolving "glume007/busybox" using unqualified-search registries (/etc/containers/registries.conf)
Trying to pull docker.io/glume007/busybox:v1...
Getting image source signatures
Copying blob 50783e0dfb64 [-----------------] 0.0b / 0.0b
Copying config 7a80323521 done  
Writing manifest to image destination
Storing signatures
7a80323521ccd4c2b4b423fa6e38e5cea156600f40cd855e464cc52a321a24dd

[root@congfuwuqi ~]# podman pull glume007/busybox:1
Resolving "glume007/busybox" using unqualified-search registries (/etc/containers/registries.conf)
Trying to pull docker.io/glume007/busybox:1...
Getting image source signatures
Copying blob 50783e0dfb64 [-----------------] 0.0b / 0.0b
Copying config 7a80323521 done  
Writing manifest to image destination
Storing signatures
7a80323521ccd4c2b4b423fa6e38e5cea156600f40cd855e464cc52a321a24dd

[root@congfuwuqi ~]# podman images
REPOSITORY                  TAG         IMAGE ID      CREATED      SIZE
docker.io/glume007/busybox  1           7a80323521cc  2 weeks ago  1.47 MB
docker.io/glume007/busybox  v1          7a80323521cc  2 weeks ago  1.47 MB
docker.io/library/busybox   latest      7a80323521cc  2 weeks ago  1.47 MB
Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐