1. 安装Docker 详见 Docker 安装
2. 安装Docker Compose 1 2 3 curl -L "https://github.com/docker/compose/releases/download/1.27.0/docker-compose-$(uname -s) -$(uname -m) " -o /usr/local /bin/docker-compose chmod +x /usr/local /bin/docker-compose
3. 安装Harbor 下载地址:https://github.com/goharbor/harbor/releases
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 wget https://github.com/goharbor/harbor/releases/download/v2.0.2/harbor-offline-installer-v2.0.2.tgz tar zxvf harbor-offline-installer-v2.0.2.tgz mv harbor /usr/local / cd /usr/local /harborcp harbor.yml.tmpl harbor.yml vi harbor.yml hostname: hub.elihe.io https: port: 443 certificate: /data/cert/server.crt private_key: /data/cert/server.key mkdir -p /data/cert && cd /data/cert openssl genrsa -des3 -out server.key 2048 openssl req -new -key server.key -out server.csr cp server.key server.key.org openssl rsa -in server.key.org -out server.key openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt chmod a+x * cd /usr/local /harbor./install.sh docker-compose start vi /etc/rc.d/rc.local /usr/local /bin/docker-compose -f /usr/local /harbor/docker-compose.yml up -d crontab -e @reboot sleep 60 && /usr/local /bin/docker-compose -f /usr/local /harbor/docker-compose.yml up -d
4. Harbor服务器和客户端配置 1 2 3 4 5 6 7 8 9 10 11 echo "192.168.31.200 hub.elihe.io" >> /etc/hostsvi /etc/docker/daemon.json { "insecure-registries" : ["https://hub.elihe.io" ] } systemctl daemon-reload && systemctl restart docker
5. 访问Harbor 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 https://hub.elihe.io admin/Harbor12345 docker login https://hub.elihe.io docker pull nginx docker tag nginx hub.elihe.io/library/nginx:v1 cat index.html echo 'Hello MyApp | Version: v1 | <a href="hostname.html">Pod Name</a>' > index.htmlcat > hostname.html <<EOF <script type="text/javascript"> document.write(location.hostname); </script> EOF docker commit 7e7553b2204f hub.elihe.io/library/nginx:v1 docker push hub.elihe.io/library/nginx:v1