[Docker]docker pull image with proxy
記錄一下遇到的狀況.
要自己build image
的時候, 要先拉一份外面的image
, 但因為外網不會通, 所以要透過proxy server
出去.
本來以為用export
就可以, 實際上測試是要另外輸入參數或是要在build/pull
當下帶參數.
Example 當下帶指令
docker build --build-arg HTTP_PROXY=http://<ip>:<port> .
Example export
export HTTP_Proxy=http://<ip>:<port>
docker build --build-arg HTTP_PROXY .
最後決定一勞永逸, 直接設定Docker
走Proxy
建立資料夾並進入到資料夾內
mkdir -p /etc/systemd/system/docker.service.d
cd /etc/systemd/system/docker.service.d
新增檔案並寫入
vim http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://<ip>:<port>"
Environment="HTTPS_PROXY=http://<ip>:<port>"
重新讀取 & 重啟服務
systemctl daemon-reload
systemctl restart docker
然後再pull一次就可以了
docker pull ubuntu:latest