1

I am trying to use docker-compose build behind a corporate proxy, but for some reason none of the areas where you insert the proxy settings seem to allow it to complete the steps.

I am using a CentOS 8 server.

The error message:

[root@centos8server docker]# docker-compose build
    postgres uses an image, skipping
    start_dependencies uses an image, skipping
    Building custom-docker

    Step 1/15 : FROM swift:5.2.3 as builder
    ---> 67a9c8f156c1

    Step 2/15 : ARG env
    ---> Using cache
    ---> b767ab90fbe8

    Step 3/15 : RUN apt-get -qq update && apt-get install -y   libssl-dev zlib1g-dev   && rm -r /var/lib/apt/lists/*
    ---> Running in b935c12d0bbd
    W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Temporary failure resolving 'archive.ubuntu.com'
    W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
    W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
    W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
    W: Some index files failed to download. They have been ignored, or old ones used instead.

    Reading package lists...
    Building dependency tree...
    Reading state information...
    E: Unable to locate package libssl-dev

    ERROR: Service 'custom-docker' failed to build: The command '/bin/sh -c apt-get -qq update && apt-get install -y   libssl-dev zlib1g-dev   && rm -r /var/lib/apt/lists/*' returned a non-zero code: 100

My initial thought was that the CentOS server was using apt and apt-get which doesn't exist, but I then built the server at home without proxy restrictions at it just worked. I can wget the addresses and have no issues there.

I have tried adding proxies in the following areas:

1. proxy for build and compose

Except I didn't have a .docker folder in any of the user accounts so I created the directory and file

nano ~/.docker/config.json
{
    "proxies": {
        "default": {
            "httpProxy": "http://proxy.server:port",
            "httpsProxy": "http://proxy.server:port",
            "noProxy": "localhost,127.0.0.1"
        }
    }
}

2. Proxy for environment

3. Proxy for sysconfig

The only thing I do know that has been an issue in the past is our proxy is Basic-Auth but haven't been able to find out how to add that or if it is necessary to add in.

markb
  • 1,100
  • 1
  • 15
  • 40

1 Answers1

1

You need to add the proxy settings within the Dockerfile itself:

# above apt-get
ENV http_proxy http://user:password@proxy.domain.ltd:[PORT]
ENV https_proxy http://user:password@proxy.domain.ltd:[PORT]

# above git
# basic proxy auth if needed
RUN git config --global http.proxy http://user:password@proxy.domain.ltd:[PORT] && \
    git config --global https.proxy http://user:password@proxy.domain.ltd:[PORT] && \
    git config --global http.proxyAuthMethod 'basic' && \
    git config --global https.proxyAuthMethod 'basic'
markb
  • 1,100
  • 1
  • 15
  • 40