赞
踩
[root@localhost ~]# ps -aux |grep podman root 4452 0.0 0.0 9212 1180 pts/0 S+ 10:10 0:00 grep --color=auto podman [root@localhost ~]# ps -aux |grep docker root 1282 0.6 2.2 1442352 83664 ? Ssl 10:09 0:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock root 4638 0.0 0.0 9212 1156 pts/0 S+ 10:10 0:00 grep --color=auto docker [root@localhost ~]# yum -y install podman ... Removed: containerd.io-1.6.7-3.1.el8.x86_64 docker-ce-3:20.10.17-3.el8.x86_64 docker-ce-rootless-extras-20.10.17-3.el8.x86_64 Complete! [root@localhost ~]# podman version Client: Podman Engine Version: 4.0.2 API Version: 4.0.2 Go Version: go1.17.7 Built: Tue Mar 15 15:15:06 2022 OS/Arch: linux/amd64 [root@localhost ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE [root@localhost ~]#
修改podman镜像源(podman默认的镜像拉取镜像地址第一个是红帽的,从红帽去拉去,而且可能要都要涉及到红帽的一个付费用户才行的,最后一个才是正儿八经的docker的镜像仓库的源,所以把他这个顺序调整一下,把docker的镜像仓库的源调整到第一位置上去,如果不调整的话,他装软件他会优先跑到上去,结果红帽的连接不上去,就会导致安装特别慢)
[root@localhost ~]# vim /etc/containers/registries.conf
unqualified-search-registries = ["docker.io"]
#配置加速器
[[registry]]
prefix = "docker.io"
location = "fi54miqv.mirror.aliyuncs.com"
–help是查看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 events Show podman events ...
podman pull 下载拉去镜像
注意**:Podman在不同的注册管理机构中搜索。因此,建议使用完整的映像名称(docker.io/library/httpd而不是httpd)来确保使用正确的映像**
[root@localhost ~]# podman pull docker.io/library/httpd
Trying to pull docker.io/library/httpd:latest...
Getting image source signatures
Copying blob d982c879c57e done
Copying blob dcc4698797c8 done
Copying blob 67283bbdd4a0 done
Copying blob a2abf6c4d29d done
Copying blob 41c22baa66ec done
Copying config dabbfbe0c5 done
Writing manifest to image destination
Storing signatures
dabbfbe0c57b6e5cd4bc089818d3f664acfad496dc741c9a501e72d15e803b34
podman images 查看镜像列表
[root@localhost ~]# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/httpd latest dabbfbe0c57b 7 months ago 148 MB
[root@localhost ~]#
podman run 的用法.参数
run:是在创建容器后,运行他
-d是在后台运行
-it是人机交互
–name是创建容器名字
-p是映射端口
-e是指定host
run后面-d是在后台运行--name是容器的名字,为web -p是做主机和容器的端口映射,然后就是镜像名版本号,我这里是默认的版本号。
[root@localhost ~]# podman run -d --name web -p 80:80 docker.io/library/httpd
a74945c89b2966adf4094b18a2f49d7c977ff437cb19e4126ffcd96f0158b2b3
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
[root@localhost ~]#
podman ps是列出正在运行的容器,没有运行和的
[root@localhost ~]# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a74945c89b29 docker.io/library/httpd:latest httpd-foreground 49 seconds ago Up 49 seconds ago 0.0.0.0:80->80/tcp web
[root@localhost ~]#
podman ps -a是列出所有的容器不管有没有在运行中
[root@localhost ~]# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a74945c89b29 docker.io/library/httpd:latest httpd-foreground 9 minutes ago Up 9 minutes ago 0.0.0.0:80->80/tcp web
[root@localhost ~]#
podman status: 查看运行中容器资源使用情况
[root@localhost ~]# podman stats web
ID NAME CPU % MEM USAGE / LIMIT MEM % NET IO BLOCK IO PIDS CPU TIME AVG CPU %
a74945c89b29 web 5.87% 17.13MB / 3.885GB 0.44% 1.658kB / 2.735kB -- / -- 82 97.471674ms 5.87%
podman top显示容器正在运行的进程
[root@localhost ~]# podman top -l
USER PID PPID %CPU ELAPSED TTY TIME COMMAND
root 1 0 0.000 20m39.564486817s ? 0s httpd -DFOREGROUND
www-data 8 1 0.000 20m39.564604327s ? 0s httpd -DFOREGROUND
www-data 9 1 0.000 20m39.565176547s ? 0s httpd -DFOREGROUND
www-data 10 1 0.000 20m39.565307091s ? 0s httpd -DFOREGROUND
[root@localhost ~]#
podman stop:停止容器
[root@localhost ~]# podman stop web
web
[root@localhost ~]# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a74945c89b29 docker.io/library/httpd:latest httpd-foreground 21 minutes ago Exited (0) 8 seconds ago 0.0.0.0:80->80/tcp web
[root@localhost ~]#
podman tag:重命名(不覆盖源镜像文件)
[root@localhost ~]# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/httpd latest dabbfbe0c57b 7 months ago 148 MB
[root@localhost ~]# podman tag docker.io/library/httpd:latest docker.io/httpd:v0.1
[root@localhost ~]# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/httpd latest dabbfbe0c57b 7 months ago 148 MB
docker.io/library/httpd v0.1 dabbfbe0c57b 7 months ago 148 MB
[root@localhost ~]#
podman exec 是进入容器退出但容器还在
[root@localhost ~]# podman exec -it web /bin/bash
root@a74945c89b29:/usr/local/apache2#
root@a74945c89b29:/usr/local/apache2#
root@a74945c89b29:/usr/local/apache2# ^C
root@a74945c89b29:/usr/local/apache2# exit
exit
[root@localhost ~]# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a74945c89b29 docker.io/library/httpd:latest httpd-foreground 31 minutes ago Up About a minute ago 0.0.0.0:80->80/tcp web
[root@localhost ~]#
podman network reload web 重载规则
[root@localhost ~]# podman network reload web
a74945c89b2966adf4094b18a2f49d7c977ff437cb19e4126ffcd96f0158b2b3
[root@localhost ~]#
podman commit 制作镜像
[root@localhost ~]# podman commit -p k1
Getting image source signatures
Copying blob 01fd6df81c8e skipped: already exists
Copying blob b721ee47211c done
Copying config bb96f9ad50 done
Writing manifest to image destination
Storing signatures
bb96f9ad5020c7e162e24d1e9138b5ce7828a313bc720a9dc97e89f2254392cc
[root@localhost ~]#
[root@localhost ~]# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> bb96f9ad5020 51 seconds ago 1.47 MB
docker.io/library/busybox latest beae173ccac6 7 months ago 1.46 MB
podman info 查看详细信息
[root@localhost ~]# podman info
host:
arch: amd64
buildahVersion: 1.24.1
cgroupControllers:
docker.io:
Blocked: false
Insecure: false
Location: fi54miqv.mirror.aliyuncs.com
你可以看到加速器
podman 登录
上传镜像必须要先登录官方的网站
[root@localhost ~]# podman login
Username: nuanchun
Password:
Login Succeeded!
[root@localhost ~]#
错误解决:
如果podman login报错这种
Error: authenticating creds for "docker.io": pinging container registry registry-1.docker.io: Get "https://registry-1.docker.io/v2/": net/http: TLS handshake timeout
就需要进入
vim /etc/docker/daemon.json
{
"registry-mirrors":["docker.mirrors.ustc.edu.cn"]
}
加入这一行配置然后在登陆就可以了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。