本文主要是介绍podman简介与安装与常用基础命令,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
podman简介与安装与常用基础命令
文章目录
- podman简介与安装与常用基础命令
- 1 podman简介
- 2:podman与docker的差别
- 3:安装podman与配置
- 4 podman容器常用基础命令
- podman run
- start启动容器
- ps 查看容器
- stop 停止容器
- restart 重启容器
- attch 进入容器
- exec 进入容器
- rm 删除容器
- logs 查看日志
- 5:podman镜像常用基础命令
- search 检索镜像
- 获取镜像
- images 列出镜像
- image ls 列出镜像
- rmi 删除镜像
- image rm 删除镜像
- tag 标记本地镜像,将其归入某一仓库。
- login 登录到一个镜像仓库
- push 上传镜像
1 podman简介
Podman(Pod Manager)是一个功能齐全的容器引擎,是一个简单的无守护程序工具。Podman提供了一个与Docker-CLI类似的命令行,可以轻松地从其他容器引擎过渡,并允许管理Pod、容器和图像。简单地说: alias docker=podman 。大多数Podman命令都可以作为普通用户运行,而不需要额外的权限。
Podman在内部使用Buildah(1)创建容器映像。这两个工具共享图像(而不是容器)存储,因此每个工具都可以使用或操作对方创建的图像(但不能操作容器)。
标志的默认设置在中定义 containers.conf 。远程连接的大多数设置都使用服务器的tainers.conf,手册页中记录的情况除外。
2:podman与docker的差别
dockers在实现CRI的时候,它需要一个守护进程,以root权限运行这样会带来安全隐患,而podman不需要守护进程和root权限。
在docker的运行体系中,需要多个daemon才能调用到OCI的实现RunC。
在容器管理的链路中,Docker Engine的实现就是dockerd
daemon,它在linux中需要以root运行,dockerd调用containerd,containerd调用containerd-shim,然后才能调用runC。顾名思义shim起的作用也就是“垫片”,避免父进程退出影响容器的运行
3:安装podman与配置
安装podman
[root@localhost ~]# yum -y install podman
配置podman
[root@localhost ~]# vim /etc/containers/registries.conf
# unqualified-search-registries = ["registry.fedoraproject.org", "registry.access.redhat.com", "registry.centos.org", "docker.io"]unqualified-search-registries = ["docker.io"]
[[registry]]
prefix = "docker.io"
location = "wlfs9l74.mirror.aliyuncs.com"
4 podman容器常用基础命令
podman run
创建并启动容器
[root@localhost ~]# podman run --name httpd busybox:latest
start启动容器
[root@localhost ~]# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d36984b8d048 docker.io/library/busybox:latest sh About a minute ago Up 3 seconds ago httpd
ps 查看容器
[root@localhost ~]# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d36984b8d048 docker.io/library/busybox:latest sh 12 seconds ago Up 12 seconds ago httpd
stop 停止容器
[root@localhost ~]# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d36984b8d048 docker.io/library/busybox:latest sh 12 seconds ago Up 12 seconds ago httpd
[root@localhost ~]# podman stop httpd
[root@localhost ~]# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d36984b8d048 docker.io/library/busybox:latest sh 41 seconds ago Exited (137) 8 seconds ago httpd
restart 重启容器
[root@localhost ~]# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d36984b8d048 docker.io/library/busybox:latest sh 2 minutes ago Up About a minute ago httpd
[root@localhost ~]# podman restart httpd
[root@localhost ~]# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d36984b8d048 docker.io/library/busybox:latest sh 2 minutes ago Up 1 second ago httpd
attch 进入容器
[root@localhost ~]# podman attach httpd
/ #
exec 进入容器
[root@localhost ~]# podman exec -it httpd /bin/sh
/ #
rm 删除容器
[root@localhost ~]# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d36984b8d048 docker.io/library/busybox:latest sh 8 minutes ago Up 2 minutes ago httpd
[root@localhost ~]# podman rm -f httpd
[root@localhost ~]# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
logs 查看日志
[root@localhost ~]# podman logs httpd
5:podman镜像常用基础命令
search 检索镜像
[root@localhost ~]# podman search httpd
NAME DESCRIPTION
docker.io/library/httpd The Apache HTTP Server Project
docker.io/clearlinux/httpd httpd HyperText Transfer Protocol (HTTP) server program with the benefits of Clear Linux OS
docker.io/centos/httpd-24-centos7 Platform for running Apache httpd 2.4 or building httpd-based application
获取镜像
[root@localhost ~]# podman pull centos
Resolved "centos" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull quay.io/centos/centos:latest...
Getting image source signatures
Copying blob 7a0437f04f83 done
Copying config 300e315adb done
Writing manifest to image destination
Storing signatures
300e315adb2f96afe5f0b2780b87f28ae95231fe3bdd1e16b9ba606307728f55
[root@localhost ~]# podman images
quay.io/centos/centos latest 300e315adb2f 20 months ago 217 MB
images 列出镜像
[root@localhost ~]# podman images
quay.io/centos/centos latest 300e315adb2f 20 months ago 217 MB
image ls 列出镜像
quay.io/centos/centos latest 300e315adb2f 20 months ago 217 MB
rmi 删除镜像
[root@localhost ~]# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/busybox latest beae173ccac6 7 months ago 1.46 MB
docker.io/ningnoob/ceshi g1 beae173ccac6 7 months ago 1.46 MB
localhost/ningnoob/ceshi c1 beae173ccac6 7 months ago 1.46 MB
quay.io/centos/centos latest 300e315adb2f 20 months ago 217 MB
[root@localhost ~]#
[root@localhost ~]# podman rmi localhost/ningnoob/ceshi:c1
Untagged: localhost/ningnoob/ceshi:c1
[root@localhost ~]# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/busybox latest beae173ccac6 7 months ago 1.46 MB
docker.io/ningnoob/ceshi g1 beae173ccac6 7 months ago 1.46 MB
quay.io/centos/centos latest 300e315adb2f 20 months ago 217 MB
image rm 删除镜像
[root@localhost ~]# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/busybox latest beae173ccac6 7 months ago 1.46 MB
docker.io/ningnoob/ceshi g1 beae173ccac6 7 months ago 1.46 MB
quay.io/centos/centos latest 300e315adb2f 20 months ago 217 MB
[root@localhost ~]# podman image rm docker.io/ningnoob/ceshi:g1
Untagged: docker.io/ningnoob/ceshi:g1
[root@localhost ~]# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/busybox latest beae173ccac6 7 months ago 1.46 MB
quay.io/centos/centos latest 300e315adb2f 20 months ago 217 MB
tag 标记本地镜像,将其归入某一仓库。
[root@localhost ~]# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/busybox latest beae173ccac6 7 months ago 1.46 MB
quay.io/centos/centos latest 300e315adb2f 20 months ago 217 MB
[root@localhost ~]#
[root@localhost ~]# podman tag docker.io/library/busybox:latest docker.io/ningnoob/ceshi:s1
[root@localhost ~]# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/busybox latest beae173ccac6 7 months ago 1.46 MB
docker.io/ningnoob/ceshi s1 beae173ccac6 7 months ago 1.46 MB
quay.io/centos/centos latest 300e315adb2f 20 months ago 217 MB
login 登录到一个镜像仓库
[root@localhost ~]# podman login
Username: ningnoob
Password:
Login Succeeded!
push 上传镜像
[root@localhost ~]# podman push docker.io/ningnoob/ceshi:s1
Getting image source signatures
Copying blob 01fd6df81c8e skipped: already exists
Copying config beae173cca done
Writing manifest to image destination
Storing signatures
这篇关于podman简介与安装与常用基础命令的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!