【原创】运维基础之Docker(3)搭建私有仓库

下载并启动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

早期docker版本(1.10及之前)不支持insecure-registries,需要改为

# vi /etc/sysconfig/docker
OPTIONS='--selinux-enabled --insecure-registry=localhost:5000 --log-driver=journald'

再push即可

$ curl http://localhost:5000/v2/_catalog
{"repositories":["mynginx"]}

上一篇:51nod 1138 连续整数的和 好题


下一篇:奶牛过马路(排序+前缀最值)