server1,server2 (其中server1作為私有庫伺服器,server2作為普通客戶端)
(相關推薦:docker教學)
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"]}
因為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私有庫的具體方法的詳細內容。更多資訊請關注PHP中文網其他相關文章!