Docker Hub

时间:2019-11-21
本文章向大家介绍Docker Hub,主要包括Docker Hub使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

目前Docker官方维护了一个公共仓库https://hub.docker.com, 其中已经包括100000+个的镜像。大部分需求都可以通过在 Docker hub中直接下载镜像来实现,

注册登录

可以在https://hub.docker.com 免费注册一个Docker账号。在命令行执行docker login输入用户名及密码来完成在命令行界面登记Docker Hub。你可以通过docker logout退出登录。

docker login

拉取镜像

可以通过docker search命令来查找官方仓库中的镜像,并利用docker pull命令来将它下载到本地。

推送镜像

用户也可以在登录后通过docker push命令来将自己的镜像推送到Docker Hub。

docker pull tomcat
 docker images

修改本地镜像的名字为账号名/镜像名

上传镜像到公共仓库

docker push woxpp/tomcat-test:latest

登录界面查看

docker pull woxpp/tomcat-test

私有仓库

有时候使用Docker Hub这样的公共仓库可能不方便,用户可以创建一个本地仓库供私人使用。比如,基于公司内部项目构建的镜像。
docker-registry是官方提供的工具,可以用于构建私有的镜像仓库。

安装运行docker-registry

可以通过获取官方registry镜像来运行。默认情况下,仓库会被创建在容器的/var/lib/registry目录下。可以通过-v参数来将镜像文件存放在本地的指定路径。

docker run --name registry -d  -p 5000:5000 --restart=always  -v /opt/registry:/var/lib/registry registry
docker ps -a

测试是否成功

http://192.168.50.24:5000/v2/_catalog

使用docker tag将session-web:latest这个镜像标记为192.168.50.24:5000/session-web:latest格式为docker tag IMAGE:TAG/]REPOSITORY[:TAG]

1
docker tag docker.io/tomcat 192.168.50.24:5000/tomcat-2:latest

使用docker push上传标记的镜像

docker push 192.168.50.24:5000/tomcat-2:latest

验证上传的镜像

http://192.168.50.24:5000/v2/_catalog

 先删除已有镜像,再尝试从私有仓库中下载这个镜像。

docker images
 docker rmi 192.168.50.24:5000/tomcat-2
docker pull 192.168.50.24:5000/tomcat-2 

注意事项

The push refers to a repository [192.168.50.24:5000/consul]
Get https://192.168.50.24:5000/v1/_ping: http: server gave HTTP response to HTTPS client

可以用下面方式解决

修改客户端/etc/docker/daemon.json中写入如下内容

{
    "registry-mirror":[
        "http://hub-mirror.c.163.com"
    ],
    "insecure-registries":[
        "192.168.50.24:5000"
    ]
}

重新启动docker后再试试
service docker restart

http://www.wu0553.com/news/59927.html
http://www.wu0553.com/news/59925.html
http://www.wu0553.com/news/59923.html
http://www.wu0553.com/news/59921.html
http://www.wu0553.com/news/59918.html
http://www.wu0553.com/news/59914.html
http://www.wu0553.com/news/59911.html
http://www.wu0553.com/news/59909.html
http://www.wu0553.com/news/59905.html
http://www.wu0553.com/news/59902.html
http://www.wu0553.com/news/59899.html
http://www.wu0553.com/news/59895.html
http://www.wu0553.com/news/59894.html
http://www.wu0553.com/news/59892.html
http://www.wu0553.com/news/59889.html
http://www.wu0553.com/news/59883.html
http://www.wu0553.com/news/59879.html
http://www.wu0553.com/news/59878.html
http://www.wu0553.com/news/59876.html
http://www.wu0553.com/news/59875.html
http://www.wu0553.com/news/59872.html
http://www.wu0553.com/news/59869.html
http://www.wu0553.com/news/59866.html
http://www.wu0553.com/news/59863.html
http://www.wu0553.com/news/59859.html
http://www.wu0553.com/news/59856.html
http://www.wu0553.com/news/59853.html
http://view.szonline.net/yule/15138.html
http://view.szonline.net/yule/15135.html
http://view.szonline.net/yule/15134.html
http://view.szonline.net/yule/15133.html
http://view.szonline.net/yule/15132.html
http://view.szonline.net/yule/15131.html
http://view.szonline.net/yule/15130.html
http://view.szonline.net/yule/15129.html
http://view.szonline.net/yule/15128.html
http://view.szonline.net/yule/15127.html
http://view.szonline.net/yule/15126.html
http://view.szonline.net/yule/15125.html
http://view.szonline.net/yule/15124.html
http://view.szonline.net/yule/15123.html
http://view.szonline.net/yule/15122.html
http://view.szonline.net/yule/15121.html
http://view.szonline.net/yule/15120.html
http://view.szonline.net/yule/15119.html
http://view.szonline.net/yule/15118.html
http://view.szonline.net/yule/15117.html
http://view.szonline.net/yule/15116.html
http://view.szonline.net/yule/15115.html
http://view.szonline.net/yule/15114.html
http://view.szonline.net/yule/15113.html
http://view.szonline.net/yule/15112.html
http://view.szonline.net/yule/15111.html
http://view.szonline.net/yule/15110.html
http://market.szonline.net/amaz/24803.html
http://market.szonline.net/amaz/24802.html
http://market.szonline.net/amaz/24801.html
http://market.szonline.net/amaz/24800.html
http://market.szonline.net/amaz/24799.html
http://market.szonline.net/amaz/24798.html
http://market.szonline.net/amaz/24797.html
http://market.szonline.net/amaz/24796.html
http://market.szonline.net/amaz/24795.html
http://market.szonline.net/amaz/24794.html
http://market.szonline.net/amaz/24793.html
http://market.szonline.net/amaz/24792.html
http://market.szonline.net/amaz/24791.html
http://market.szonline.net/amaz/24790.html
http://market.szonline.net/amaz/24789.html
http://market.szonline.net/amaz/24788.html
http://market.szonline.net/amaz/24787.html
http://market.szonline.net/amaz/24786.html
http://market.szonline.net/amaz/24785.html
http://market.szonline.net/amaz/24784.html
http://market.szonline.net/amaz/24783.html
http://market.szonline.net/amaz/24782.html
http://market.szonline.net/amaz/24781.html
http://market.szonline.net/amaz/24780.html
http://market.szonline.net/amaz/24779.html
http://market.szonline.net/amaz/24778.html
http://market.szonline.net/amaz/24777.html
http://market.szonline.net/amaz/24776.html
http://market.szonline.net/amaz/24775.html
http://market.szonline.net/amaz/24768.html
http://market.szonline.net/amaz/24758.html
http://market.szonline.net/amaz/24757.html
http://market.szonline.net/amaz/24753.html

原文地址:https://www.cnblogs.com/cider/p/11906822.html