系统配置: CentOS 7
内核 3.10.0-229.20.1.el7.x86_64
, Docker version 1.8.2
运行 docker registry
执行下列命令:
复制代码 代码如下:
docker run / -d / --name private_registry --restart=always / -e SETTINGS_FLAVOUR=dev / -e STORAGE_PATH=/registry-storage / -v /data/docker/private-registry/storage:/registry-storage / -u root / -p 5000:5000 / registry:2
如果本地已有registry镜像,它会直接运行,否则它会到docker hub共有仓库下载之后再运行, -v /data/docker/private-registry/storage:/registry-storage
该命令将之后私有仓库的镜像存放到本地。
之后执行:
复制代码 代码如下:
docker tag docker.io/docker:1.8 192.168.100.9:5000/docker:1.8 docker push 192.168.100.9:5000/docker:1.8
这时会报很多错误:
复制代码 代码如下:
FATA[0000] Error response from daemon: v1 ping attempt failed with error: Get https://192.168.100.9:5000/v1/_ping: tls: oversized record received with length 20527/. If this private registry supports only HTTP or HTTPS with an unknown CA certificate,please add `--insecure-registry 192.168.100.9:5000` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/192.168.100.9:5000/ca.crt
最简单的解决方法是修改 /etc/sysconfig/docker
文件添加 INSECURE_REGISTRY='--insecure-registry 192.168.100.9:5000'
, Ubuntu 14.04 的配置文件在 /etc/default/docker
在该文件里添加 DOCKER_OPTS="--insecure-registry 192.168.100.9:5000"
,添加过之后重启 docker ,重新运行 docker registry 即可生效。这样做的缺点是你的私有仓库不安全,其次,其他要下载或者上传镜像的机器都要修改相应的配置文件。
安全的做法是去认证机构购买签名证书,在此我们使用自认证的方式。
自签名认证
首先执行:
复制代码 代码如下:
# mkdir -p certs && openssl req / -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key / -x509 -days 365 -out certs/domain.crt Country Name (2 letter code) [AU]:CN State or Province Name (full name) [Some-State]:Beijing Locality Name (eg, city) []:Beijing Organization Name (eg, company) [Internet Widgits Pty Ltd]:SERCXTYF Organizational Unit Name (eg, section) []:IT Common Name (e.g. server FQDN or YOUR name) []:192.168.100.9:5000 Email Address []:xxx.yyy@ymail.com
生成认证证书和密钥。接下来将刚生成的 certs/domain.crt 复制到 /etc/docker/certs.d/192.168.100.9:5000/ca.crt ,之后重启 docker 并运行:
复制代码 代码如下:
docker run / -d / --name private_registry --restart=always / -e SETTINGS_FLAVOUR=dev / -e STORAGE_PATH=/registry-storage / -v /data/docker/private-registry/storage:/registry-storage / -u root / -p 5000:5000 / -v /root/certs:/certs / -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt / -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key / registry:2
这样之后应该可以成功了吧,于是执行:
# docker push 192.168.100.9:5000/docker:1.8
结果它还是报错了:
复制代码 代码如下:
The push refers to a repository 192.168.100.9:5000/docker:1.8 unable to ping registry endpoint https://192.168.100.9:5000/v0/ v2 ping attempt failed with error: Get https://192.168.100.9:5000/v2/: x509: cannot validate certificate for 192.168.100.9 because it doesn't contain any IP SANs v1 ping attempt failed with error: Get https://192.168.100.9:5000/v1/_ping: x509: cannot validate certificate for 192.168.100.9 because it doesn't contain any IP SANs
解决方法:修改 /etc/pki/tls/openssl.cnf 配置,在该文件中找到 [ v3_ca ] ,在它下面添加如下内容:
复制代码 代码如下:
[ v3_ca ] # Extensions for a typical CA subjectAltName = IP:123.56.157.144
之后再次重启docker,并重新 run registry ,启动成功之后,执行:
复制代码 代码如下:
# docker push 192.168.100.9:5000/docker:1.8 The push refers to a repository [192.168.100.9:5000/docker] (len: 1) 793ab2f3d322: Pushed e1232be51d09: Pushed 71ef33d4e0e5: Pushed e9d235d200dc: Pushed 3fb9a265fbfc: Pushed 9f50b4b1f00b: Pushed 413668359dd0: Pushed da0daae25b21: Pushed f4fddc471ec2: Pushed 1.8: digest: sha256:28a02a8a50b750a300904b53e802bdf76516d591b2d233ae21cf771b8c776d44 size: 17621
至此,上传终于成功。换台机器下载刚上传的镜像:
复制代码 代码如下:
# docker pull 192.168.100.9:5000/docker:1.8 Trying to pull repository 192.168.100.9:5000/docker ... failed unable to ping registry endpoint https://192.168.100.9:5000/v0/ v2 ping attempt failed with error: Get https://192.168.100.9:5000/v2/: x509: certificate signed by unknown authority v1 ping attempt failed with error: Get https://192.168.100.9:5000/v1/_ping: x509: certificate signed by unknown authority
仔细分析错误信息,发现是没有证书,将在 192.168.100.9 上生成的证书拷贝到相应的目录下 /etc/docker/certs.d/192.168.100.9:5000/ca.crt
,拷贝之后重启 docker ,再次执行:
复制代码 代码如下:
# docker pull 192.168.100.9:5000/docker:1.8 1.8: Pulling from docker 9d58b928bc15: Pull complete dbe7e8a7807c: Pull complete ce14982b73d4: Pull complete b9f70905d763: Pull complete b9c93a2fb3cf: Pull complete 1321a4d5d3ea: Pull complete 5941048a7e27: Pull complete f57edf7c2e71: Pull complete 5de2ade00f1b: Pull complete Digest: sha256:28a02a8a50b750a300904b53e802bdf76516d591b2d233ae21cf771b8c776d44 Status: Downloaded newer image for 192.168.100.9:5000/docker:1.8
至此, docker registry 私有仓库安装成功。如果要部署到生产环境还需要进一步的配置,具体可以参考Registry Configuration Reference。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?
更新日志
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]