/ # cat /etc/docker/registry/config.yml version: 0.1 log: fields: service: registry storage: cache: blobdescriptor: inmemory filesystem: rootdirectory: /var/lib/registry http: addr: :5000 headers: X-Content-Type-Options: [nosniff] health: storagedriver: enabled: true interval: 10s threshold: 3 / # [root@localhost ~]# docker run -it --rm --name jj registry:2 /bin/sh
當本地主機運行 Registry 服務後,全部能訪問到該主機的 Docker Host 均可以把它做爲 私有倉庫使用,只須要在鏡像名稱前面添加上具體的服務器地址便可。 例如將本地的nginx 推入本身的倉庫linux
私有倉庫須要啓用 TLS 認證,不然會報錯。 在第一部分中,咱們介紹了經過添加 DOCKER_ OPTS="--insecure-registry yourhostname:5000" (此版本下的docker沒有這個硬性要求)nginx
[root@localhost ~]# docker version Client: Version: 18.09.3 API version: 1.39 Go version: go1.10.8 Git commit: 774a1f4 Built: Thu Feb 28 06:33:21 2019 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 18.09.3 API version: 1.39 (minimum version 1.12) Go version: go1.10.8 Git commit: 774a1f4 Built: Thu Feb 28 06:02:24 2019 OS/Arch: linux/amd64 Experimental: false
推拉鏡像docker
docker images docker tag nginx:alpine localhost:5000/nginx/alpine docker push localhost:5000/nginx/alpine