簡體   English   中英

Docker,企業代理(使用 PX 反向代理)在 Dockerfile 中使用“apk add”添加新包時無法執行 DNS 查找

[英]Docker, Corporate Proxy (using PX Reverse Proxy) fails to do DNS lookup when adding new packages within Dockerfile with 'apk add'

我開始在公司內部使用 Docker 工作,但我的 Docker 桌面出現網絡問題。

我的系統設置是:

  • Windows 10 企業
  • Docker 台式機 (4.3.2)
  • 連接到 Inte.net 的公司代理
  • PX 代理 (0.5.0)作為反向代理,默認在端口 3128 上運行。

我只是嘗試按照 Dockers 說明從入門開始對示例 node.js 應用程序進行 dockerize,由於RUN apk add... (見下文),我無法構建它

步。

首先嘗試docker build -t getting-started. 通常應該做簡單的事情。

結果是: DNSRUN apk add --no-cache python2 g++ make指令中查找錯誤。 從 Dockerfile 內部調用 inte.net 似乎不是一件小事:-(。

Output: 在此處輸入圖像描述

第二次嘗試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 連接和防火牆)

Output: 在此處輸入圖像描述

我的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

Docker 桌面代理配置: 在此處輸入圖像描述

在 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM