1.安裝docker-compose1.下載docker-compose的最新版本html
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
2.爲docker-compose添加可執行權限linux
chmod +x /usr/local/bin/docker-compose
3.驗證查看docker-compose版本git
docker-compose --versiongithub
若是docker compose的版本過低會提示以下錯誤:redis
2.安裝Harbor
1)下載Harbor https://github.com/goharbor/harbor/releases ( 推薦離線安裝包) docker
tar -zxvf harbor-offline-installer-v1.8.0.tgz #解壓離線安裝包
mv harbor /opt/ #移到/opt目錄下
cd /opt #進入到/opt目錄
cd harbor
ll #查看目錄內容
進入harbor目錄修改harbor.yml 文件以下(我這裏下載的離線安裝的版本):json
而後安裝ubuntu
./prepare
./install.shwindows
注意docker 裏面不要有redis容器 否者會有提示for redis Cannot create container for service redis: Conflictapp
3.使用Harbor
進入http://192.168.100.3
1.增長倉庫地址:
文件目錄:/etc/docker/daemon.json (沒有則新建該文件)
{ "insecure-registries":["192.168.100.3:80"] }
或者用指令 echo '{ "insecure-registries":["192.168.100.3:80"] }' > /etc/docker/daemon.json
重啓dcoker:service docker restart
網上還有一種方法是:
修改 /lib/systemd/system/docker.service 在ExecStart的最後增長:--insecure-registry=198.168.100.3:80
修改docker.service必定要執行systemctl daemon-reload刷新配置 ,而後重啓 systemctl restart docker
鏈接本地的harbor
若是是windows ,右擊docker圖標,在settings裏的Deamon的Insecure registries裏增長Harbor的IP和端口,docker會自動重啓
2.push 鏡像
爲了以防用戶信息錯亂 能夠先logout 而後在login
docker logout 192.168.100.3:80
docker login 192.168.100.3:80
a.新建repo-test私有倉庫,
#拉取鏡像 docker pull hello-world #給鏡像打tag(鏡像的格式爲,鏡像倉庫IP:端口/鏡像名稱) docker tag hello-world 192.168.100.3:80/repo-test/hello-world:20190720 #PUSH到倉庫 docker push 192.168.100.3:80/repo-test/hello-world
若是遇到以下錯誤:
root@gavin-vm:~# docker push 192.168.100.3:80/hello-world
The push refers to repository [192.168.100.3:80/hello-world]
af0b15c8625b: Retrying in 5 seconds
實際上是打tag時打的不對 經過命令journalctl -u docker.service 或者 查看日誌文件/var/log/harbor/registry.log查看錯誤日誌
----2019-8-14 補充
如圖所示 每當ubuntu重啓後 harbor的某些容器不能自動啓動起來
也嘗試過修改container的啓動參數 docker container update --restart=always 容器名字/ID (禁止命令 docker container update --restart=no 容器名字/ID ),可是查看 /opt/harbor/docker-compose.yml文件裏面確實有 restart: always
解決方案就是:將 harbor配成systemd的service,添加配置文件 /etc/systemd/system/harbor.service,內容以下:
[Unit] Description=Harbor After=docker.service systemd-networkd.service systemd-resolved.service Requires=docker.service Documentation=http://github.com/vmware/harbor [Service] Type=simple Restart=on-failure RestartSec=5 ExecStart=/usr/local/bin/docker-compose -f /opt/harbor/docker-compose.yml up ExecStop=/usr/local/bin/docker-compose -f /opt/harbor/docker-compose.yml down [Install] WantedBy=multi-user.target
而後啓動該服務:
sudo systemctl enable harbor
sudo systemctl start harbor
重啓再看,發現 harbor 容器組終於所有 up 了:
參考地址
How To Install and Use Docker Compose on Ubuntu 18.04