Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

106.2. podman 管理

	
cp /etc/containers/registries.conf{,.original}
	
	

106.2.1. 虚拟机管理

			
$ podman machine init	# 初始化
$ podman machine start	# 启动 podman VM
$ podman machine stop	# 停止VM
$ podman machine list	# 罗列VM
$ podman machine rm		# 删除VM
$ podman machine ssh	# 通过SSH 进入VM,在终端进行操作
			
		

106.2.1.1. 管理 Podman 系统

			
$ podman system --help
    
neo@MacBook-Pro-Neo ~> podman system connection list
Name                         URI                                                         Identity                                Default
podman-machine-default       ssh://core@localhost:59590/run/user/501/podman/podman.sock  /Users/neo/.ssh/podman-machine-default  true
podman-machine-default-root  ssh://root@localhost:59590/run/podman/podman.sock           /Users/neo/.ssh/podman-machine-default  false

$ podman system df
    TYPE           TOTAL       ACTIVE      SIZE        RECLAIMABLE
    Images         29          0           8.931GB     8.931GB (100%)
    Containers     0           0           0B          0B (0%)
    Local Volumes  1           0           0B          0B (0%)
    
$ podman system info	
			
			

106.2.2. 镜像管理

106.2.2.1. 切换国内镜像源

			
cat >> /etc/containers/registries.conf <<EOF

unqualified-search-registries = ["docker.io"]

[[registry]]
prefix = "docker.io"
location = "hub-mirror.c.163.com"
insecure = true

[[registry.mirror]]
# 百度镜像源
location = "mirror.baidubce.com"
insecure = true
[[registry.mirror]]
# 网易 163 镜像源
location = "hub-mirror.c.163.com"
insecure = true
[[registry.mirror]]
# 上海交大镜像源
location = "docker.mirrors.sjtug.sjtu.edu.cn"
insecure = true
[[registry.mirror]]
# 南京大学镜像源
location = "docker.nju.edu.cn"
insecure = true
EOF
			
			
			
[root@netkiller ~]# podman info | grep Location:
    Location: hub-mirror.c.163.com
      Location: hub.uuuadc.top
      Location: docker.anyhub.us.kg
      Location: dockerhub.jobcher.com
      Location: dockerhub.icu
      Location: docker.ckyl.me
      Location: docker.awsl9527.cn			
			
			

106.2.2.2. 搜索镜像

docker.io 官方镜像

			
[root@localhost ~]# podman search httpd --filter=is-official
			
			

106.2.2.3. 获取镜像

			 
[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 45a0cdc5c8d3 done  
Copying config 334e4a014c done  
Writing manifest to image destination
Storing signatures
334e4a014c81bd4050daa78c7dfd2ae87855e9052721c164ea9d9d9a416ebdd3		
			
			

106.2.2.4. 查看镜像

			 
[root@localhost ~]# podman image ls
REPOSITORY                 TAG         IMAGE ID      CREATED      SIZE
docker.io/library/busybox  latest      334e4a014c81  13 days ago  5.09 MB		
			
			

106.2.3. 运行命令

		 
$ podman pull maven
$ podman run -v ~/.m2:/root/.m2 \
-v /root/bottleneck:/root/bottleneck \
-w /root/bottleneck \
maven:latest \
mvn package