下载并启动registry
$ docker pull registry
$ docker run --name my_registry -d -p 5000:5000 -v /var/lib/registry:/var/lib/registry registry
从官方仓库下载nginx并push到私有仓库中
$ docker pull nginx
$ docker tag nginx localhost:5000/mynginx
$ docker push localhost:5000/mynginx
push报错
The push refers to repository [localhost:5000/nginx]
Get https://localhost:5000/v2/: http: server gave HTTP response to HTTPS client
解决方法
$ echo '{ "insecure-registries":["localhost:5000"] }' > /etc/docker/daemon.json
$ service docker restart
再push即可
$ curl http://localhost:5000/v2/_catalog
{"repositories":["mynginx"]}