目的
將對容器的變更保存并提交到自己的鏡像倉庫中
前提條件
- 1 安裝Docker
- 2 注冊DockerHub用戶
- 3 下載容器鏡像
實施
- 對容器修改并提交
例如在當前容器中安裝pip
[root@b9bc56403642 /]# python get-pip.py
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |################################| 1.3MB 13kB/s
Collecting setuptools
Downloading setuptools-36.2.0-py2.py3-none-any.whl (477kB)
100% |################################| 481kB 13kB/s
Collecting wheel
Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
100% |################################| 71kB 14kB/s
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-9.0.1 setuptools-36.2.0 wheel-0.29.0
[root@b9bc56403642 /]# pip -V
pip 9.0.1 from /usr/lib/python2.7/site-packages (python 2.7)
退出容器
[root@b9bc56403642 /]# exit
exit
提交修改
docker@default:~$ sudo docker commit b9b teitiyuu/atp-centos
sha256:1ac7fcc09ecd9878e528db9f38df635d441cffe0f5c4879c188d4115d657fe93
docker@default:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
teitiyuu/atp-centos latest 1ac7fcc09ecd 11 seconds ago 313MB
daocloud.io/centos latest 8140d0c64310 2 months ago 193MB
- DockerHub用戶登錄
docker@default:~$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: teitiyuu
Password:
Login Succeeded
- 提交鏡像
docker@default:~$ docker push teitiyuu/atp-centos:latest
The push refers to a repository [docker.io/teitiyuu/atp-centos]
b2d6ace8e407: Pushed
b51149973e6a: Pushed
latest: digest: sha256:ebbc18663b17a566f3cb479e364f354db85e9945ae3f2b2e660d47258059f79f size: 741
docker@default:~$
- DockerHub