I started to work with Docker within our Company and have a network issue within my Docker Desktop.
my system setup is:
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 :-(.
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.
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= de\username
[settings]
workers = 3
threads = 8
idle = 30
socktimeout = 20.0
foreground = 0
log = 0
Docker Desktop Proxies Configuration:
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?
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"]