# Docker login 解法 | 初學者登入 http Harbor 的方式 > [time= May, 2021] 出現類似這樣的 error msg: ### Error response from daemon: Get https://xxx.xxx.xxx.xxx/v2/: dial tcp xxx.xxx.xxx.xxx:443: connect: connection refused 是因為基本 docker 都會走 443 port,然後你的 harbor 沒有憑證。 (不過還真的有時候會遇到像是是在測試環境 / Legacy issue 有一個 http 版 harbor要連?) 總之因為各種原因要走 http 版 harbor 的話,此時快速調整成讓 docker login 不走 https 的方式,也就是本文主軸,請參考以下步驟: ### 1. 修改 Docker 的 daemon : default 坐落在 `/etc/docker/daemon.json` 如果沒有的話在相同路徑新增也可以, 加入insecure-registries 在裡頭: ``` { "insecure-registries" : ["harbor-domain.com:5000", "0.0.0.0"] } ``` ### 2. 找到 docker.service : ``` lyahsuan@ubuntu:~/harbor$ find / -name docker.service -type f /usr/lib/systemd/system/docker.service ``` ### 3. 修改docker.service配置文件: 將 `Documentation=https://docs.docker.io` 改成 `Documentation=http://docs.docker.io` : ``` lyahsuan@ubuntu:~/harbor$ vim /usr/lib/systemd/system/docker.service [Unit] Documentation=http://docs.docker.io ... [Service] Type=notify ... ``` ### 4. 停止harbor 後重啟: ``` lyahsuan@ubuntu:~/harbor$ docker-compose down -v lyahsuan@ubuntu:~/harbor$ systemctl daemon-reload lyahsuan@ubuntu:~/harbor$ systemctl restart docker lyahsuan@ubuntu:~/harbor$ docker-compose up -d ``` ### 成功登入! ``` lyahsuan@ubuntu:~/harbor$ docker login xxx.xxx.xxx.xxx 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 ``` --- 此篇分享可不代表推薦大家使用不安全的harbor喔。 基本上這個情境比較像給初學者想先簡單看一個 registry 可以繞過憑證的一個方式。 這也只是我試成功的一個做法,總之本篇也順便讓大家複習一下 docker.service 這個檔案有多重要,你各位啊~容器環境資安就從注意這裡開始。 Tschüss! (ノ>ω<)ノ ###### tags: `work hack` `VMware` `Tanzu` `harbor` `repository` `docker` `container`