[英]Docker, Corporate Proxy (using PX Reverse Proxy) fails to do DNS lookup when adding new packages within Dockerfile with 'apk add'
我開始在公司內部使用 Docker 工作,但我的 Docker 桌面出現網絡問題。
我的系統設置是:
我只是嘗試按照 Dockers 說明從入門開始對示例 node.js 應用程序進行 dockerize,由於RUN apk add...
(見下文),我無法構建它
步。
首先嘗試: docker build -t getting-started.
通常應該做簡單的事情。
結果是: DNS在RUN apk add --no-cache python2 g++ make
指令中查找錯誤。 從 Dockerfile 內部調用 inte.net 似乎不是一件小事:-(。
第二次嘗試: docker build -t getting-started. --build-arg HTTP_PROXY=http://localhost:3128 --build-arg HTTPS_PROXY=http://localhost:3128
docker build -t getting-started. --build-arg HTTP_PROXY=http://localhost:3128 --build-arg HTTPS_PROXY=http://localhost:3128
這次我也在同一步驟中遇到網絡錯誤(檢查 Inte.net 連接和防火牆) 。
我的Dockerfile看起來和教程中的一樣。
FROM node:12-alpine
# Adding build tools to make yarn install work on Apple silicon / arm64 machines
RUN apk add --no-cache python2 g++ make
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "src/index.js"]
在同一目錄中,我有示例應用程序,正如所提到的入門教程中所述。
px.ini 文件:
[proxy]
server = my.company.com:8080
port = 3128
listen = 127.0.0.1
gateway = 1
hostonly = 0
noproxy = 127.0.0.*,10.*.*.*,192.168.*.*
allow = *.*.*.*
username= de\username
[settings]
workers = 3
threads = 8
idle = 30
socktimeout = 20.0
foreground = 0
log = 0
在 web 中進行了許多研究,例如在 stackoverflow、論壇等處。我發現這很可能是網絡配置問題的提示。
有誰知道,我在這里做錯了什么? Docker 應該如何正確設置公司代理和反向代理作為 CNTLM 或 PX 代理?
我也通過在 Dockerfile 中使用環境變量解決了我的問題。
FROM node:12-alpine
ARG http_proxy=http://host.docker.internal:3128
ARG https_proxy=http://host.docker.internal:3128
# Adding build tools to make yarn install work on Apple silicon / arm64
machines
RUN apk add --no-cache python2 g++ make
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "src/index.js"]
在 dockerfile 中添加以下兩行幫助我解決了這個問題。
ARG http_proxy=http://host.docker.internal:3128
ARG https_proxy=http://host.docker.internal:3128
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.