podman
文章目录
podman的介绍
Podman 是一个开源项目,可在大多数 Linux 平台上使用,并位于GitHub 上。Podman 是一个无守护进程的容器引擎,用于在 Linux 系统上开发、管理和运行 Open Container Initiative (OCI) 容器和容器映像。
安装部署podman
[root@localhost ~]yum -y install podman
[root@localhost ~]# podman -help
Manage pods, containers and images
Usage:
podman [options] [command]
Available Commands:
attach Attach to a running container
auto-update Auto update containers according to their auto-update policy
build Build an image using instructions from Containerfiles
commit Create new image based on the changed container
container Manage containers
cp Copy files/folders between a container and the local filesystem
create Create but do not start a container
diff Display the changes to the object's file system
.......
[root@localhost ~]# podman version
Version: 3.4.1-dev
API Version: 3.4.1-dev
Go Version: go1.16.7
Built: Wed Oct 20 00:11:42 2021
OS/Arch: linux/amd64
podman基础命令
info
显示 podman 系统信息
-
[root@localhost ~]# podman info host: arch: amd64 buildahVersion: 1.23.1 cgroupControllers: - cpuset - cpu - cpuacct - blkio - memory - devices - freezer - net_cls - perf_event - net_prio - hugetlb - pids - rdma cgroupManager: systemd cgroupVersion: v1 ........
login和logout
login:登录到容器注册表
logout:注销容器注册表
[root@localhost ~]# podman login docker
Username: yqz1234
Password:
Login Succeeded!
[root@localhost ~]# podman logout
Removed login credentials for docker
diff
diff:检查容器文件系统上的更改
[root@localhost ~]# podman diff centos
A /var/db
A /var/spool
A /var/spool/lpd
A /var/spool/mail
A /bin
A /lib64
A /mnt
........
history
history:显示指定图像的历史记录
[root@localhost ~]# podman image history centos
ID CREATED CREATED BY SIZE COMMENT
300e315adb2f 20 months ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0 B
<missing> 20 months ago /bin/sh -c #(nop) LABEL org.label-schema.... 0 B
<missing> 20 months ago /bin/sh -c #(nop) ADD file:bd7a2aed6ede423... 217 MB
inspect
inspect:检查显示容器或图像的配置
[root@localhost ~]# podman image inspect centos
[
{
"Id": "300e315adb2f96afe5f0b2780b87f28ae95231fe3bdd1e16b9ba606307728f55",
"Digest": "sha256:8301d100020ffaedc93f57d8c8bb0e8e88006862bcb48ebc5dfbe1d1cb83060c",
"RepoTags": [
"quay.io/centos/centos:latest"
],
"RepoDigests": [
"quay.io/centos/centos@sha256:8301d100020ffaedc93f57d8c8bb0e8e88006862bcb48ebc5dfbe1d1cb83060c",
save
save:镜像保存到本地
[root@localhost ~]# podman image save centos > centos.tar
[root@localhost ~]# ls
anaconda-ks.cfg centos.tar daemon.json html software start.sh yyz
load
load:从tar存档加载镜像
[root@localhost ~]# podman image load < centos.tar
Getting image source signatures
Copying blob 2653d992f4ef skipped: already exists
Copying config 300e315adb done
Writing manifest to image destination
Storing signatures
Loaded image(s): quay.io/centos/centos:latest
[root@localhost ~]# podman image list
REPOSITORY TAG IMAGE ID CREATED SIZE
quay.io/centos/centos latest 300e315adb2f 20 months ago 217 MB
search
search:搜素镜像
[root@localhost ~]# podman image search busybox
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/library/busybox Busybox base image. 2712 [OK]
docker.io docker.io/rancher/busybox 0
docker.io docker.io/ibmcom/busybox 0
docker.io docker.io/openebs/busybox-client 0
docker.io docker.io/antrea/busybox 0
docker.io docker.io/ibmcom/busybox-amd64
pull
pull:拉取镜像
[root@localhost ~]# podman image 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
tag
tag:为本地图像添加附加名称
[root@localhost ~]# podman tag busybox yqz/busybox:v0.1
[root@localhost ~]# podman image list
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/busybox latest 7a80323521cc 2 weeks ago 1.47 MB
localhost/yqz/busybox v0.1 7a80323521cc 2 weeks ago 1.47 MB
quay.io/centos/centos latest 300e315adb2f 20 months ago 217 MB
create
create:创建一个或多个容器
[root@localhost ~]# podman container create centos
0f5c3eb79fd326b7decce2fced0e9a025f72f8e0a8ee62db9186295e934bb8a6
[root@localhost ~]# podman container create --name alg centos
35bf495d5a602ae8c789f587350b48d4b5c3d614fd67b7ddbb64ef8e876cd44f
start
start:启动一个或多个容器
[root@localhost ~]# podman container start 0f5c3eb79fd3 alg
0f5c3eb79fd3
alg
tree
tree:以树格式打印镜像的图层层次结构
[root@localhost ~]# podman image tree busybox
Image ID: 7a80323521cc
Tags: [docker.io/library/busybox:latest localhost/yqz/busybox:v0.1]
Size: 1.468MB
Image Layers
└── ID: 084326605ab6 Size: 1.463MB Top Layer of: [docker.io/library/busybox:latest localhost/yqz/busybox:v0.1]
list
list:列出本地存储的镜像
[root@localhost ~]# podman image list
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/busybox latest 7a80323521cc 2 weeks ago 1.47 MB
localhost/yqz/busybox v0.1 7a80323521cc 2 weeks ago 1.47 MB
quay.io/centos/centos latest 300e315adb2f 20 months ago 217 MB