Docker Hub官网:https://hub.docker.com/
[root@localhost ~]# docker login Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one. Username: gaoyufu Password: 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 [root@localhost ~]# docker push centos:testdocker-compose这个命令可以管理harbor服务,不过需要注意的是想使用以下命令,必须是和 docker-compose.yml 这个文件在同一个目录下
[root@localhost harbor]# docker-compose start | stop | restart //启动|停止|重启使用IP或者域名登录皆可 默认用户名:admin 密码:123456
将这里的harbor.gyf.com替换成你的域名即可 1、安装openssl证书工具
[root@localhost ~]# yum -y install openssl2、创建证书存放文件夹
[root@localhost ~]# mkdir /usr/local/harbor/certs3、生成无加密的根证书私钥(注意一定要进到证书目录)
[root@localhost ~]# cd /usr/local/harbor/certs/ [root@localhost certs]# openssl genrsa -out ca.key 40964、使用刚才生成的私钥制作自签名证书
[root@localhost certs]# openssl req -x509 -new -nodes -sha512 -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=harbor.gyf.com/OU=harbor.gyf.com/CN=harbor.gyf.com" -key ca.key -out ca.crt5、生成服务器端自己域名的key
[root@localhost certs]# openssl genrsa -out harbor.gyf.com.key 40966、生成服务器端自己域名的CSR签名请求
[root@localhost certs]# openssl req -sha512 -new -subj "/C=CN/ST=Beijing/L=Beijing/O=harbor.gyf.com/OU=harbor.gyf.com/CN=harbor.gyf.com" -key harbor.gyf.com.key -out harbor.gyf.com.csr7、生成一个 openssl 命令需要的外部配置文件 xexternalfile.ext
[root@localhost certs]# cat > xexternalfile.ext <<-EOF authorityKeyIdentifier=keyid,issuer basicConstraints=CA:FALSE keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment extendedKeyUsage = serverAuth subjectAltName = @alt_names [alt_names] DNS.1=harbor.gyf.com EOF8、通过外部配置文件 xexternalfile.ext和 csr 生成 crt
[root@localhost certs]# openssl x509 -req -sha512 -days 3650 -extfile xexternalfile.ext -CA ca.crt -CAkey ca.key -CAcreateserial -in harbor.gyf.com.csr -out harbor.gyf.com.crt9、将服务端的 crt 转换成客户端用的 cert
[root@localhost certs]# openssl x509 -inform PEM -in harbor.gyf.com.crt -out harbor.gyf.com.cert [root@localhost certs]# ls ca.crt ca.srl harbor.gyf.com.crt harbor.gyf.com.key ca.key harbor.gyf.com.cert harbor.gyf.com.csr xexternalfile.ext10、启动服务后访问
[root@localhost certs]# cd /usr/local/harbor/ [root@localhost harbor]# ./install.sh [root@localhost ~]# mkdir -p /etc/docker/certs.d/harbor.gyf.com [root@localhost ~]# cd /etc/docker/certs.d/harbor.gyf.com/ [root@localhost harbor.gyf.com]# cp /usr/local/harbor/certs/harbor.gyf.com.crt . [root@localhost ~]# docker login https://harbor.gyf.com Username: admin Password: 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 [root@localhost ~]# docker push harbor.gyf.com/test/web:v1 The push refers to repository [harbor.gyf.com/test/web] 88b680b1fdfc: Pushed 843c3701e622: Pushed 3ba8a4f66ba2: Pushed c865989f86f7: Pushed d0f104dc0a1f: Pushed v1: digest: sha256:fc717ed0d0b55ada05af1c1a95a2d4ee1153a5858fd65b654644a1a5add0c28b size: 1367