快速搭建docker私有倉庫https

搭建倉庫的服務器:A

拉去推送的服務器:B

A:node

openssl req \
  -newkey rsa:4096 -nodes -sha256 -keyout ./domain.key \
  -x509 -days 365 -out ./domain.crt

Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:GD
Locality Name (eg, city) []:SZ
Organization Name (eg, company) [Internet Widgits Pty Ltd]:COMPANY
Organizational Unit Name (eg, section) []:IT_SECTION
Common Name (e.g. server FQDN or YOUR name) []:your.domain.com
Email Address []:

注意:Common Name (e.g. server FQDN or YOUR name) []:your.domain.com 這一步填入域名git

啓動(證書位置替換爲本身的):docker

docker run -d \
  --restart=always \
  --name registry \
  -v /root/certs:/certs \
  -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
  -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \
  -p 5000:5000 \
  registry:2

B:服務器

  1. vi /etc/hosts 加入 192.168.1.3 your.domain.com 注意:A服務器上填寫的域名dom

  2. 複製第一步中生成的 domain.crt 到 /etc/docker/certs.d/myregistrydomain.com:5000/ca.crt,路徑中的域名注意替換成實際第一步中填寫的rest

  3. 重啓dockercode

sudo systemctl daemon-reload
sudo systemctl restart docker
  1. 執行docker pull xxxx docker push xxxx
相關文章
相關標籤/搜索