Docker 镜像发布(七)
本文介绍如何将镜像发布到阿里云镜像仓库和本地私有仓库,以及本地私有仓库部署。
登录阿里云官网,找到容器镜像服务,如果没有则手动创建一个,如下图所示:
示例:将本地镜像 myubuntu:v1
推送到阿里云仓库
bash[root@10-60-55-35 ~]# docker login --username=aliyun8029235972 registry.cn-hangzhou.aliyuncs.com
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
bash[root@10-60-55-35 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest a6bd71f48f68 13 days ago 187MB
6053537/portainer-ce latest b9c565f94ccc 5 weeks ago 322MB
portainer/helper-reset-password latest c56588a8080c 6 months ago 43.5MB
hello-world latest 9c7a54a9a43c 7 months ago 13.3kB
[root@10-60-55-35 ~]# docker tag a6bd71f48f68 registry.cn-hangzhou.aliyuncs.com/lxc_blog/blog:latest
[root@10-60-55-35 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest a6bd71f48f68 13 days ago 187MB
registry.cn-hangzhou.aliyuncs.com/lxc_blog/blog latest a6bd71f48f68 13 days ago 187MB
bashdocker push registry.cn-hangzhou.aliyuncs.com/lxc_blog/blog:1.0.0
bashdocker pull registry.cn-hangzhou.aliyuncs.com/lxc_blog/blog:1.0.0
bashdocker pull registry
bashdocker run -d -p 5000:5000 -v /data/myregistry:/tmp/registry --privileged=true registry
bash[root@localhost ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://6l7dxkas.mirror.aliyuncs.com"],
"insecure-registries": ["192.168.6.80:5000"]
}
注意:配置文件格式为json格式,条目之间要有空格分隔。
bashsystemctl restart docker
示例:将本地镜像 nginx:latest
推送到阿里云仓库
bash[root@10-60-55-35 ~]# docker tag nginx:latest 117.50.172.33:5000/nginx:latest
[root@10-60-55-35 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry latest 909c3ff012b7 3 days ago 25.4MB
117.50.172.33:5000/nginx latest a6bd71f48f68 13 days ago 187MB
nginx latest a6bd71f48f68 13 days ago 187MB
bashdocker push 117.50.172.33:8080/nginx:latest
bash[root@localhost ~]# curl 117.50.172.33:5000/v2/_catalog
{"repositories":["mynginx"]}
bash[root@localhost ~]# curl -XGET http://117.50.172.33:5000/v2/nginx/tags/list
{"name":"mynginx","tags":["1.2"]}
bashdocker pull 117.50.172.33:5000/nginx:1.2
本文作者:LiuXueChao
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!