Docker_提交容器到镜像+提交后的镜像重新启用为容器
1、创建一个新的容器ping_software(备用)
docker run -itd --name ping_software ubuntu /bin/bash
创建成功后的效果
2、进入该容器,下载所需的软件包
docker attach 961e81735e46
apt-get update
apt install iputils-ping
3、提交容器镜像
docker commit -m="update ping" -a="ping_rongqi" 961e81735e46 ping_images
成功的效果
4、提交后的镜像重新启用为容器(test1和test2)
docker run -itd --name test1 --network test-net 0ea90498852d /bin/bash
docker run -itd --name test2 --network test-net 0ea90498852d /bin/bash
5、验证互通效果
进入容器1,ping容器2
docker attach 8c0bc184776d
root@8c0bc184776d:/#
root@8c0bc184776d:/#
root@8c0bc184776d:/# ping test2
进入容器2,ping容器1
[root@localhost softRyc]# docker attach 8cd550f8ef06
root@8cd550f8ef06:/#
root@8cd550f8ef06:/#
root@8cd550f8ef06:/# ping test1