映象上傳、存入、存出
首先得去https://www.docker.com/ 官網註冊一個賬號
1.上傳映象
[[email protected] docker]# docker tag test:latest dy1999/test:latest
[[email protected] docker]# 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: dy1999
Password:
Login Succeeded
[[email protected] docker]# docker push dy1999/test:latest 其中dy1999為我剛註冊的使用者名稱 test為docker網站上的倉庫名 沒有會自動建立 latest為標籤
The push refers to a repository [docker.io/dy1999/test]
a473a4bafa40: Pushed
a8de0e025d94: Pushed
a5e66470b281: Pushed
ac7299292f8b: Pushed
e1a9a6284d0d: Pushed
fccbfa2912f0: Pushed
latest: digest: sha256:3545bfcb3fd004ce0c3489a5f10dbbf92187ea2cb89c0aaf6e5c3946981b263f size: 1564
2.存出
cd /var/opt/docker 上傳檔案 ubuntu-14.04-x86_64-minimal.tar.gz
[[email protected] docker]# sudo cat ubuntu-14.04-x86_64-minimal.tar.gz |docker import - ubuntu:14.04
會輸出sha256:cd7ac3dace3edc17b80b933a2c43976be0068c83fb749d8fc7a559a04f43dcdf
[[email protected] docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 14.04 cd7ac3dace3e About a minute ago 215 MB
test latest 131466eb2ab0 23 minutes ago 113 MB
docker.io/ubuntu latest c9d990395902 4 days ago 113 MB
docker.io/centos latest e934aafc2206 10 days ago 199 MB
docker.io/learn/tutorial latest a7876479f1aa 5 years ago 128 MB
存出本地的映象為檔案ubuntu_14.04.tar
[[email protected] docker]# docker save -o ubuntu_14.04.tar ubuntu:14.04
會 在/var/opt/docker 建立ubuntu_14.04.tar檔案
3.存入
docker load --input ubuntu_14.04.tar 載入映象
或者docker load < ubuntu_14.04.tar
[[email protected] docker]# docker load < ubuntu_14.04.tar
輸出Loaded image: ubuntu:14.04