注意:修改容器内容之后需要执行
podman commit -a "作者名字" 容器ID d容器名称:版本号
- 拉取
podman pull 镜像名称
- 查看已经下载的镜像
podman images
- 查看正在运行的容器
podman ps
- 运行一个容器
podman run -d -p 8082:8080 tomcat
-d代表后台运行,-p端口号映射 本机:容器 tomcat是启动tomcat容器 - 删除镜像
podman rmi -f 名称
- 删除容器
podman rm 名称
- 进入到容器内部
podman exec -i -t 容器名称 /bin/bash
使用exit推出 - 传文件到容器:在主机操作命令(非容器内部)
podman cp Seventh_SSM-2.0-RELEASE dockerTomcat:webapps/
编辑文件
编辑docker容器中的文件一般docker中没有VI或者其它相应的文本编辑器,
为了写个东西安装个vi就可以解决问题,
除此之外还有别的办法
登陆docker中找到需要编辑的文件的位置
通过docker cp把这个文件拷贝出来
sudo docker cp xxxx:/etc/mysql/my.cnf /home/tom/
再拷贝回去
sudo docker cp /home/tom/my.cnf xxxx:/etc/mysql/
注意这个xxxx是docker ps -a 获取的container id
23号
- 导出
[root@k8s-master ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest ae513a47849c 2 months ago 109MB
debian jessie 4eb8376dc2a3 2 months ago 127MB
rabbitmq 3.6.8 8cdcbee37f62 15 months ago 179MB
[root@k8s-master tmp]# docker save ae513a47849c > nginx-save.tar
[root@k8s-master tmp]# ls -lh
total 108M
-rw-r--r-- 1 root root 108M Jul 4 09:32 nginx-save.tar
- 导入
[root@k8s-master tmp]# ls -lh
total 108M
-rw-r--r-- 1 root root 108M Jul 4 09:32 nginx-save.tar
[root@k8s-master tmp]# docker load < nginx-save.tar
82b81d779f83: Loading layer [==================================================>] 54.21MB/54.21MB
7ab428981537: Loading layer [==================================================>] 3.584kB/3.584kB
Loaded image ID: sha256:ae513a47849c895a155ddfb868d6ba247f60240ec8495482eca74c4a2c13a881