因为不用
https
协议的话,docker
客户端需要修改配置,如果docker
客户端多的话配置起来就很麻烦。
CentOS Linux 7.6 Release
18.09.6
1.24.1
harbor-offline-installer-v1.9.0
172.0.0.11
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
systemctl restart docker.service
systemctl start docker
systemctl enable docker
curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
yum install -y bash-completion
curl -L https://raw.githubusercontent.com/docker/compose/1.24.1/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose
docker-compose --version
1.8
或者 1.9
版本,切记配置文件中 https
需要顶格,证书和 port
需要缩进相同单位,不然会报错。ca
证书mkdir -p /data/cert
cd /data/cert
CA
的 key
cd /data/cert
openssl genrsa -out ca.key 4096
CA
的 crt
cd /data/cert
openssl req -x509 -new -nodes -sha512 -days 3650 \
-subj "/C=CN/ST=Beijing/L=Beijing/O=chinatelecom/OU=ecloudcaas/CN=172.0.0.11" \
-key ca.key \
-out ca.crt
key
cd /data/cert
openssl genrsa -out 172.0.0.11.key 4096
csr
cd /data/cert
openssl req -sha512 -new \
-subj "/C=CN/ST=Beijing/L=Beijing/O=chinatelecom/OU=ecloudcaas/CN=172.0.0.11" \
-key 172.0.0.11.key \
-out 172.0.0.11.csr
openssl
命令需要的外部配置文件主要是subjectAltName,这里写的IP.1=yourip还可以写DNS.1=yourdomainname
cd /data/cert
cat > v3.ext <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
IP=172.0.0.11
EOF
ext
和 csr
生成 crt
cd /data/cert
openssl x509 -req -sha512 -days 3650 \
-extfile v3.ext \
-CA ca.crt -CAkey ca.key -CAcreateserial \
-in 172.0.0.11.csr \
-out 172.0.0.11.crt
crt
转换成客户端用的 cert
cd /data/cert
openssl x509 -inform PEM -in 172.0.0.11.crt -out 172.0.0.11.cert
cert
,key
和 ca.crt
拷贝到 docker client 所在主机的 /etc/docker/certs.d/yourdomain/
目录下mkdir -p /etc/docker/cert/172.0.0.11
cp /data/cert/172.0.0.11.cert /etc/docker/cert/172.0.0.11/
cp /data/cert/172.0.0.11.key /etc/docker/cert/172.0.0.11/
cp /data/cert/ca.crt /etc/docker/cert/172.0.0.11/
/etc/docker/daemon
cat > /etc/docker/daemon.json << EOF
{ "insecure-registries":["http://172.0.0.11"] }
EOF
docker
systemctl daemon-reload
systemctl restart docker
Harbor
harbor
离线包mkdir -p /home/harbor/
wget -P /home/harbor/ https://storage.googleapis.com/harbor-releases/release-1.9.0/harbor-offline-installer-v1.9.0.tgz
cd /home/harbor/
tar xf harbor-offline-installer-v1.9.0.tgz
cd /home/harbor/harbor
cp harbor.yml harbor.yml.bak
cd /home/harbor/harbor/
[root@harbor harbor]# egrep -v "^#|^$" harbor.yml|grep -v "#"
https:
port: 443
certificate: /home/harbor/cert/172.0.0.11.crt
private_key: /home/harbor/cert/172.0.0.11.key
cd /home/harbor/harbor/
./prepare
cd /home/harbor/harbor/
./install
Harbor
的日常运维管理是通过 docker-compose
来完成的,Harbor
本身有多个服务进程,都放在 docker
容器之中运行,可以通过 docker ps
或者 docker-compose
来查看:cd /home/harbor/harbor/
[root@harbor harbor]# docker-compose ps
Name Command State Ports
----------------------------------------------------------------------------------------------------------------------------------------------
harbor-adminserver /harbor/start.sh Restarting
harbor-core /harbor/start.sh Up (health: starting)
harbor-db /entrypoint.sh postgres Up (healthy) 5432/tcp
harbor-jobservice /harbor/start.sh Up
harbor-log /bin/sh -c /usr/local/bin/ ... Up (healthy) 127.0.0.1:1514->10514/tcp
harbor-portal nginx -g daemon off; Up (healthy) 80/tcp
nginx nginx -g daemon off; Up (healthy) 0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp, 0.0.0.0:80->80/tcp
redis docker-entrypoint.sh redis ... Up 6379/tcp
registry /entrypoint.sh /etc/regist ... Up (healthy) 5000/tcp
registryctl /harbor/start.sh Up (healthy)
[root@harbor harbor]#
https://172.0.0.11
;admin / Harbor12345
;os
;centos
镜像docker pull centos:7.4.1708
TAG
docker tag centos:7.4.1708 172.0.0.11/os/centos:7.4.1708
docker images | grep centos
172.0.0.11/os/centos 7.4.1708 3afd47092a0e 2 months ago 197MB
centos 7.4.1708 3afd47092a0e 2 months ago 197MB
harbor
cat > /etc/docker/daemon.json << EOF
{ "insecure-registries":["http://172.0.0.11"] }
EOF
systemctl daemon-reload
systemctl restart docker
[root@harbor harbor]# docker login 172.0.0.11
Username: admin
Password: Harbor12345
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
docker push 172.0.0.11/os/centos:7.4.1708
harbor
中查看harbor
的 docker
客户端/etc/docker/daemon.json
文件{
"registry-mirrors": ["https:mirror.ccs.tencentyun.com","https://kuamavit.mirror.aliyuncs.com", "https://registry.docker-cn.com", "https://docker.mirrors.ustc.edu.cn"],
"insecure-registries" : ["http://172.0.0.11"],
"max-concurrent-downloads": 10,
"log-driver": "json-file",
"log-level": "warn",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
systemctl daemon-reload
systemctl restart docker
harbor
中的镜像docker login 172.0.0.11
docker pull 172.0.0.11/os/centos:7.4.1708
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。