1、容器打为镜像
[root@s40 testdocker]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
037a9e559269 nginx:1.9.7 "nginx -g 'daemon of…" 3 minutes ago Up 3 minutes 443/tcp, 0.0.0.0:37210->80/tcp, :::37210->80/tcp xnginx1
[root@s40 testdocker]#
[root@s40 testdocker]# #修改容器中的一些内容
[root@s40 testdocker]# docker exec -it 037a9e559269 bash
[root@s40 testdocker]#
[root@s40 testdocker]# #将名为037a9e559269的容器打包成名为weba:1.0的新镜像
[root@s40 testdocker]# docker commit -a 'kahn' -m "heheheshuoming" 037a9e559269 weba:1.0
[root@s40 testdocker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
weba 1.0 d26da579219a 7 seconds ago 133MB
xnginx 1.9.7 13d4b63abbd0 28 minutes
2、镜像打包到本地
[root@s40 testdocker]#
[root@s40 testdocker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
weba 1.0 d26da579219a 3 minutes ago 133MB
xnginx 1.9.7 13d4b63abbd0 32 minutes ago 133MB
root@s40 testdocker]# docker save -o weba.tar weba:1.0
[root@s40 testdocker]#
[root@s40 testdocker]# ls
weba.tar
3、本地镜像文件包导入到本地镜像仓库
[root@s40 testdocker]# ls
weba.tar
[root@s40 testdocker]# docker load -i weba.tar
c5e9f6adead0: Loading layer [==================================================>] 7.168kB/7.168kB
Loaded image: weba:1.0
[root@s40 testdocker]#