3

I am creating a docker image using DockerFile. When i execute the docker build command i get an error, below are the details

docker build -f Dockerfile.app --no-cache --rm --label 'APS_INFO=OS/CentOS/7.6/-baseurl=http://repo.lab.pl.nikhil.com/centos-remote/7.7.1908/os/x86_64/-' --label BUILDTIME=2020-03-29T09:26:54+0530 --build-arg=BASE_IMAGE=nikhil/myrepo/linuximsbase:20.5_11-Mar-2020 --build-arg=IMAGE_BUILD=admincli -t nikhil/myrepo/admincli:latest -t nikhil/myrepo/admincli:_29-Mar-2020 .

(yum:77): libdnf-WARNING **: 03:57:29.180: Skipping refresh of base: cannot update repo 'base': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried; Last error: Curl error (28): Timeout was reached for http://repo.lab.pl.nikhil.com/centos-remote/7.7.1908/os/x86_64/repodata/repomd.xml [Connection timed out after 30001 milliseconds]

I have started the docker service, using the HTTP_PROXY

....
Environment="NO_PROXY=localhost,10.200.200.3,127.0.0.1"
Environment="HTTP_PROXY=http://10.158.100.6:8080/"
Environment="HTTPS_PROXY=https://10.158.100.6:8080/"
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
....

Could you please help me what is the issue to create the Docker Image.

Note: If i do curl with the setting the same proxy details in barshrc, i am able to connect and download the repodata file.

Nikhil
  • 576
  • 1
  • 11
  • 31
  • The issue seems to be with your docker image. The base image is not created correctly and it also gets timed out. – Harshit Mar 29 '20 at 07:07
  • Please remove the proxy configuration in your bashrc file. And retry. You don't need it unless you want to download something directly from the internet. I'm from Nokia too and so very well aware of your issue. :) – vijay v Mar 29 '20 at 07:27
  • @vijay, I have removed the proxy from bashrc file, even then facing the same issue... – Nikhil Mar 29 '20 at 08:00
  • Are you copying any centos repo config in your dockerfile? can you confirm if your base docker image doesn't have any proxy settings added to it's environment or to the centos repo either? – vijay v Mar 29 '20 at 08:03
  • @Vijay, Yes i copying centos repo config in DockerFile, with proxy enabled. Base image does not have any proxy set in environment as well as centos repo. bash-4.2# env HOSTNAME=8a5866732836 TERM=xterm IMAGE_BUILD_ENV=linuximsbase.env IMAGE_BUILD_ENV_PATH=base-images/linuximsbase.env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PWD=/ SHLVL=1 HOME=/root _=/usr/bin/env – Nikhil Mar 29 '20 at 08:14
  • @Nikhil Disable proxy everywhere in your docker as long as you don't download anything from internet. Also in centos.repo files. Remove the line proxy = "" Or add proxy= _none_ in all your centos.repo files and retry. – vijay v Mar 29 '20 at 09:21
  • Please post the Dockerfile here as an EDIT so that we can check further. – vijay v Apr 10 '20 at 12:25

1 Answers1

-3

Proxy configuration needs to be provided via build args, e.g.:

docker build \
  --build-arg http_proxy=http://10.158.100.6:8080 \
  --build-arg https_proxy=http://10.158.100.6:8080 \
  ...
Jan Garaj
  • 25,598
  • 3
  • 38
  • 59
  • Proxy is already set in docker service file. It is not required to provide as argument to docker build. – Nikhil Apr 07 '20 at 04:14
  • @Nikhil did you try my suggestion or do you just think that you don't need it? Please try it. You have configured proxy via env variables for docker daemon, not for build container. Again, please try it. – Jan Garaj Apr 07 '20 at 05:52
  • Hi, I am commenting after trying out. I have tried all the possible things. 1. Passing proxy details as arguments to docker 2. Setting environment variables for proxy in DockerFile 3. Configuring proxies in ~/.docker/config.json file Trying all these combinations, no luck. – Nikhil Apr 07 '20 at 07:12
  • @Nikhil Please remove all your combinations: `1. Passing proxy details as arguments to docker 2. Setting environment variables for proxy in DockerFile 3. Configuring proxies in ~/.docker/config.json file` and use build arguments only `--build-arg http_proxy=http://10.158.100.6:8080`. You are mixing random options which you found without knowledge of their consequences. – Jan Garaj Apr 07 '20 at 08:57
  • Okay. I cleaned up all as suggested and given proxy details as docker arguments. Still no luck, facing same issue. – Nikhil Apr 07 '20 at 11:22