本篇文章为大家展示了怎么快速搭建一个docker私有库,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
准备
server1,server2 (其中server1作为私有库服务器,server2作为普通客户端)
在server1上
1 下载 registry
docker pull registry:latest
2 配置 /etc/default/docker 因为https需要证书密码等比较复杂,直接加 insecure-registry即可
# Docker Upstart and SysVinit configuration file # Customize location of Docker binary (especially for development testing). #DOCKER="/usr/local/bin/docker" # Use DOCKER_OPTS to modify the daemon startup options. #DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4" DOCKER_OPTS="--insecure-registry 127.0.0.1:5000" # If you need Docker to use an HTTP proxy, it can also be specified here. #export http_proxy="http://127.0.0.1:3128/" # This is also a handy place to tweak where Docker's temporary files go. #export TMPDIR="/mnt/bigdrive/docker-tmp"
3 启动registry
sudo docker run --name registry -d -p 5000:5000 -v /home/docker_registry:/var/lib/registry --restart=always registry:latest
4 tag镜像
docker tag redis server1:5000/redis
5 推送保存私有镜像
docker push server1:5000/redis
5.1 查看推送到私有仓库的镜像
$ docker search 10.10.105.71:5000/tonybai/busybox/ Error response from daemon: Unexpected status code 404 但通过v2版本的API,我们可以实现相同目的: $curl http://10.10.105.71:5000/v2/_catalog {"repositories":["tonybai/busybox"]}
在server2(client)上
因为docker Registry中讲到, 如果采用insecure registry的模式,那么所有与Registry交互的主机上的Docker Daemon都要配置:–insecure-registry选项。除了这个模式还可以配置证书,在此不作说明
1 配置 -insecure-registry(centos:/etc/sysconfig/docker ubuntu:/etc/default/docker)
# Docker Upstart and SysVinit configuration file # Customize location of Docker binary (especially for development testing). #DOCKER="/usr/local/bin/docker" # Use DOCKER_OPTS to modify the daemon startup options. #DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4" DOCKER_OPTS="--insecure-registry server1:5000" # If you need Docker to use an HTTP proxy, it can also be specified here. #export http_proxy="http://127.0.0.1:3128/" # This is also a handy place to tweak where Docker's temporary files go. #export TMPDIR="/mnt/bigdrive/docker-tmp"
2 下载
docker pull server1:5000/redis
3 提交推送
docker tag redis server1:5000/redis docker push server1:5000/redis
上述内容就是怎么快速搭建一个docker私有库,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。