基于Commit定制镜像
#以busybox镜像创建一个容器,在容器中创建一个hello.txt的文件。#拉取busybox 最新镜像,实际生产中,docker pull 这一步可以省略,docker run的时候会自己去拉取。
docker pull busybox
docker run --name container1 busybox touch hello.txt
#将对容器container1做出的修改提交为一个新镜像,镜像名为busybox:v1
#********** Begin *********#
docker commit container1 busybox:v1
#********** End **********#
基于save保存镜像与基于load加载镜像
#!/bin/bash#首先拉取一个busybox镜像
docker pull busybox:latest
#1.将busybox:latest镜像保存到tar包
#********** Begin *********#
docker save busybox:latest > busybox.tar
#********** End **********#
#删除busybox:latest镜像
docker rmi bus