1.Docker Registry安装
执行
# docker run -d -p 5000:5000 -v /opt/registry/data:/var/lib/registry --privileged=true --restart=always --name registry registry:latest
或者执行
docker run -d --name=my-private-registry -p 5000:5000 -v /data/registry:/var/lib/registry -e REGISTRY_AUTH=htpasswd -e REGISTRY_USERNAME=changyw -e REGISTRY_PASSWORD=123456 registry
Unable to find image 'registry:latest' locally
Trying to pull repository docker.io/library/registry ...
latest: Pulling from docker.io/library/registry
4064ffdc82fe: Pull complete
c12c92d1c5a2: Pull complete
4fbc9b6835cc: Pull complete
765973b0f65f: Pull complete
3968771a7c3a: Pull complete
Digest: sha256:003a106b827ab7f5bd7140d08020b16c87cd6bcac024b01fe6247f87632f2978
Status: Downloaded newer image for docker.io/registry:latest
2.打开浏览器访问http://localhost:5000/v2/,出现{}表示安装成功。
3.配置deamon.json
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["http://68cdf6cf.m.daocloud.io"],
"insecure-registries": ["localhost:5000"],
"exec-opts":["native.cgroupdriver=systemd"]
}
EOF
重启docker
# systemctl restart docker
# docker start registry
4.push一个镜像
docker push test333:latest
5.查看
查询Registry私有仓库镜像列表。
# curl http://localhost:5000/v2/_catalog
{"repositories":["test333"]}
查询busybox镜像的标签列表。
# curl http://localhost:5000/v2/busybox/tags/list
{"name":"test333","tags":["latest"]}
6.注意
The push refers to repository [docker.io/changyw/rescue] 这句代表push到docker.io上了
The push refers to repository [localhost:5000/test333] 这句才代表push到本地仓库
注意push前,执行一下tag命令
docker tag test333:v1 localhost:5000/test1