由容器生成镜像文件
将正在运行的容器 fee23161ee91 生成镜像文件。生成后本地多了test/mycentos:1.0.1 镜像
docker@default:~$ docker commit -m="testcreatimagesbak" -a="zxm001" fee23161ee91 test/mycentos:1.0.1
sha256:5f0869aff875e06cde2a69fec58ba148a51725a938b2b5f62575440daa44b901
docker@default:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test/mycentos 1.0.1 5f0869aff875 4 seconds ago 202MB
redis latest d3e3588af517 6 months ago 95MB
mysql latest 990386cbd5c0 6 months ago 443MB
centos latest 9f38484d220f 8 months ago 202MB
阿里云创建命名空间 mycentos如下:
登录阿里云并上传镜像
docker@default:~$ docker login --username=zhangxm_qz@163.com registry.cn-hangzhou.aliyuncs.com
Password:
WARNING! Your password will be stored unencrypted in /home/docker/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
docker@default:~$ docker tag 5f0869aff875 registry.cn-hangzhou.aliyuncs.com/zxm001/mycentos:1.0
docker@default:~$ docker push registry.cn-hangzhou.aliyuncs.com/zxm001/mycentos:1.0
The push refers to repository [registry.cn-hangzhou.aliyuncs.com/zxm001/mycentos]
9a6c1a867b4c: Mounted from zxm001/testrepos
d69483a6face: Mounted from zxm001/testrepos
1.0: digest: sha256:c2eea662622d09a6af24f16c81a8d2a86ee585a0bc9d7fd0aa0a5244b919370f size: 736
阿里云可以查看到镜像信息,登录阿里云开发者平台 https://dev.aliyun.com/search.html
从仓库下载镜像
docker@default:~$ docker pull registry.cn-hangzhou.aliyuncs.com/zxm001/mycentos:1.0
1.0: Pulling from zxm001/mycentos
8ba884070f61: Already exists
98e0c82c10fd: Pull complete
Digest: sha256:c2eea662622d09a6af24f16c81a8d2a86ee585a0bc9d7fd0aa0a5244b919370f
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/zxm001/mycentos:1.0