私有仓库nginx
[root@localhost ~]# yum info docker-registry Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Available Packages Name : docker-registry Arch : x86_64 Version : 0.9.1 Release : 7.el7 Size : 123 k Repo : extras/7/x86_64 Summary : Registry server for Docker URL : https://github.com/docker/docker-registry License : ASL 2.0 Description : Registry server for Docker (hosting/delivering of repositories and images).
[root@localhost ~]# yum install docker-registry -y [root@localhost ~]# rpm -ql docker-registry package docker-registry is not installed [root@localhost ~]# rpm -ql docker-distribution /etc/docker-distribution/registry/config.yml /usr/bin/registry /usr/lib/systemd/system/docker-distribution.service /usr/share/doc/docker-distribution-2.6.2 /usr/share/doc/docker-distribution-2.6.2/AUTHORS /usr/share/doc/docker-distribution-2.6.2/CONTRIBUTING.md /usr/share/doc/docker-distribution-2.6.2/LICENSE /usr/share/doc/docker-distribution-2.6.2/MAINTAINERS /usr/share/doc/docker-distribution-2.6.2/README.md /var/lib/registry [root@localhost ~]#
root@localhost registry]# cat config.yml version: 0.1 log: fields: service: registry storage: cache: layerinfo: inmemory filesystem: rootdirectory: /var/lib/registry http: addr: :5000 [root@localhost registry]#
启动服务 [root@localhost registry]# systemctl start docker-distribution [root@localhost registry]# ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 :::5000 :::* LISTEN 0 128 :::8080 :::* LISTEN 0 128 :::22 :::* LISTEN 0 100 ::1:25 :::* [root@localhost registry]#
建立好私有仓库以后,就能够使用 docker tag
来标记一个镜像,而后推送它到仓库。例如私有仓库地址为 127.0.0.1:5000
。 git
root@localhost registry]# docker tag httptest:v8.0 127.0.0.1:5000/myhub/ngtest:latest
[root@localhost registry]# ls
config.yml
[root@localhost registry]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
test v1.1 5f393c28297c 24 hours ago 1.2MB
test v1.0 3c7f7cac06eb 24 hours ago 1.2MB
ubuntu latest 4c108a37151f 32 hours ago 64.2MB
z1 latest 4b77198ea96d 45 hours ago 1.2MB
httptest v8.0 b42c9ee98879 45 hours ago 1.2MB
127.0.0.1:5000/myhub/ngtest latest b42c9ee98879 45 hours ago 1.2MB
httptest v7.0 ab2aff8b522c 46 hours ago 1.2MB
httptest v6.0 3299492a09ee 46 hours ago 1.2MB
httptest v5.0 98ee9a4043f8 46 hours ago 1.2MB
httptest v3.0 a1feb6df2fb0 46 hours ago 1.2MB
httptest v4.0 a1feb6df2fb0 46 hours ago 1.2MB
httpdtest v2.0 f77cae25b226 47 hours ago 2.23MB
httpdtest v3 6060a9cb9597 6 days ago 1.2MB
test v2.0 51f46a949468 2 weeks ago 1.2MB
<none> <none> 648f9e13a37c 2 weeks ago 1.2MB
zy/busybox v0.1 4c9fa4db9491 2 weeks ago 1.2MB
dockerpracticecn/docker_practice latest b6bfd54275de 5 weeks ago 41.8MB
busybox latest 64f5d945efcc 5 weeks ago 1.2MB
nginx latest 53f3fd8007f7 6 weeks ago 109MB
centos latest 9f38484d220f 3 months ago 202MB
[root@localhost registry]# docker push 127.0.0.1:5000/myhub/ngtest #使用docker push 上传镜像
The push refers to repository [127.0.0.1:5000/myhub/ngtest]
b5696abb5254: Pushed
a6f52770da32: Pushed
d1156b98822d: Pushed
latest: digest: sha256:3d23b086deb2cde6d8ac2b7c3f5e2040227f0e0914d9002d601c4be314d512a1 size: 941
[root@localhost registry]#
[root@localhost repositories]# pwd #查看镜像已经上传
/var/lib/registry/docker/registry/v2/repositories
[root@localhost repositories]# ls
myhub
[root@localhost repositories]#
若是你不想使用 127.0.0.1:5000
做为仓库地址,好比想让本网段的其余主机也能把镜像推送到私有仓库。你就得把例如 192.168.100.100:5000
这样的内网地址做为私有仓库地址,这时你会发现没法成功推送镜像。github
这是由于 Docker 默认不容许非 HTTPS
方式推送镜像。咱们能够经过 Docker 的配置选项来取消这个限制,docker
对于使用 systemd
的系统,请在 /etc/docker/daemon.json
中写入以下内容(若是文件不存在请新建该文件)json
{
"registry-mirror": [ "https://registry.docker-cn.com" ], "insecure-registries": [ "192.168.100.100:5000" ] }
注意:该文件必须符合
json
规范,不然 Docker 将不能启动。ubuntu
[root@localhost repositories]# cat /etc/docker/daemon.jsion
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
{
"dns" : [
"114.114.114.114",
"8.8.8.8"
],
"insecure-registries": [ #限制https 选项
"192.168.100.100:5000"
]
}
[root@localhost repositories]#
可视化的仓库软件centos