skip to Main Content

I started to work with Docker within our Company and have a network issue within my Docker Desktop.

my system setup is:

  • Windows 10 Enterprise
  • Docker Desktop (4.3.2)
  • Corporate Proxy to connect to the Internet
  • PX Proxy (0.5.0) as Reverse Proxy which is as default running on Port 3128.

I simply tried out to dockerize the sample node.js application from the getting-started by following Dockers instructions, which is failing for me to build due to the
RUN apk add... (see below)

step.

First try: docker build -t getting-started . which should usually do the simple thing.

Result is: DNS lookup error in the RUN apk add --no-cache python2 g++ make instruction.
It seems that calling the internet from inside the Dockerfile is not a trivial thing :-(.

Output:enter image description here

Second try: docker build -t getting-started . --build-arg HTTP_PROXY=http://localhost:3128 --build-arg HTTPS_PROXY=http://localhost:3128

This time I am getting network error (check Internet connection and firewall) also in the same step.

Output:enter image description here

My Dockerfile looks as same as in the tutorial.

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"]

In the same directory i have the sample application, just as described in the mentioned getting-started tutorial.

px.ini file:

[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= deusername
 
[settings]
workers = 3
threads = 8
idle = 30
socktimeout = 20.0
foreground = 0
log = 0

Docker Desktop Proxies Configuration:
enter image description here

Many research in the web as e.g. here at stackoverflow, in forums, etc. I found the hint that it could be very likely a network configuration problem.

Does anybody know, what I am doing wrong here?
How should Docker correctly setup with a corporate proxy and a Reverse Proxy as CNTLM or PX Proxy?

2

Answers


  1. Chosen as BEST ANSWER

    I have fixed my problem by using environment variables also within the 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"]
    

  2. Adding the following 2 lines in the dockerfile helped me to resolve this issue.

    ARG http_proxy=http://host.docker.internal:3128
    ARG https_proxy=http://host.docker.internal:3128
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search