Docker Community Forums

Share and learn in the Docker community.

Docker Compose Build Does Not Apply Proxy Settings


#1

I have Docker for Windows running on a corporate network with the proxy which is correctly configured in the Docker settings. In a directory with a simple Dockerfile, I am able to use

docker build -t buildtest .

to build an image. This confirms the proxy is correctly configured within Docker.

When I add a docker-compose.yml file and try to do the build there, it does fails and shows the error that comes from the proxy server. It doesn’t appear to be applying the proxy settings for the build process via Docker Compose.

Setting the build args in the docker-compose.yml file does not seem to help either (that was how I used to do it with Docker Toolbox, but should probably not be necessary).

Expected behavior

I expect the following to build the image defined in the docker-compose.yml file

docker-compose build buildtest

Actual behavior

When I try to build, I get the following output

docker-compose build
Building testservice
ERROR: <HTML><HEAD>`
<TITLE>Access Denied</TITLE>
...
Additional, proxy specific output saying the proxy failed to authenticate 
(omitted for brevity)
...
</BODY></HTML>

Information

  • Running Docker Version 1.12.0-rc4-beta20 (build: 5579) 4b0b82c

Steps to reproduce the behavior

  1. On a machine where a corporate proxy is required, create a new directory
  2. Add Dockerfile (see below)
  3. Run the following docker build -t buildtest .
  4. Verify the image built successfully docker images
  5. Add docker-compose.yml (see below)
  6. Run docker-compose build buildtest
  7. Observe error with output from proxy

Dockerfile

FROM alpine

RUN pwd

docker-compose.yml

version: '2'
services:
  buildtest:
    build:
      context: .

Docker-compose blocked by corporate proxy
(Rtsigler) #2

I’m having the same problem. Is there any solution or work around for this yet?


(Mtremper) #3

Same. Would be nice for a Docker rep to weigh in.


(Michael Friis) #4

Thanks for reporting this. It’s actually a little surprising that this works with docker build.

Have you tried specifying the proxy settings as build args? https://docs.docker.com/compose/compose-file/#/build

Either way, we already have an issue tracking improvements to this.

Thanks for reporting!


(Michael Friis) #5

There are more details here: https://github.com/docker/docker/issues/24697#issuecomment-235592547


(Nikki603) #6

I have this same problem and have tried using build args in the docker-compose file. Didn’t change anything, unfortunately.


(Jannovy) #7

Hi, this is really big problem for me, I can’t start any containers via docker-compose behind company proxy server.


(Michael Friis) #8

Could I get you to run diagnostics and post them on this issue which seems related: https://github.com/docker/for-win/issues/80


(Brian Albright) #9

+1 - This is a fairly big issue for me. My team’s build server sits in AWS under a different network topology from the corporate office network. The proxy settings aren’t needed in AWS, but if I pull down the code to run locally I cannot docker-compose build without manual intervention. Without this feature, portability, and especially corporate development, are significantly hindered.


(Sasiezilmadhavan) #10

Was there any solution for this problem. I am still facing issues while doing compose build. Image builds successfully with docker build. please find the command and error below

C:> docker-compose --verbose -f “C:\local\docker-compose.yml” build

compose.config.config.find: Using configuration files: C:\local\docker-compose.yml
docker.auth.find_config_file: Trying paths: ['C:\\Users\\admin\\.docker\\config.json', 'C:\\Users\\admin\\.dockercfg']
docker.auth.find_config_file: No config file found
Traceback (most recent call last):
  File "docker-compose", line 6, in <module>
  File "compose\cli\main.py", line 68, in main
  File "compose\cli\main.py", line 118, in perform_command
  File "compose\cli\command.py", line 37, in project_from_options
  File "compose\cli\command.py", line 99, in get_project
  File "compose\cli\command.py", line 74, in get_client
  File "site-packages\docker\api\daemon.py", line 177, in version
  File "site-packages\docker\utils\decorators.py", line 46, in inner
  File "site-packages\docker\api\client.py", line 189, in _get
  File "site-packages\requests\sessions.py", line 488, in get
  File "site-packages\requests\sessions.py", line 475, in request
  File "site-packages\requests\sessions.py", line 617, in send
  File "site-packages\requests\sessions.py", line 177, in resolve_redirects
  File "site-packages\requests\sessions.py", line 596, in send
  File "site-packages\requests\adapters.py", line 499, in send
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='proxy.mydomain.com', port=8080): Read timed out. (read timeout=60)
Failed to execute script docker-compose

(Exhuma) #11

I’m having the same issue on Linux. I have set the proxies in ~/.docker/config.json but the values seem to be ignored by docker-compose.

Manually setting them using build/args in docker-compose.yml does not seem to work either. I have:

version: "2"
services:
  web:
    build:
      context: .
      args:
        - http_proxy = "http://localproxy.localdomain",
        - https_proxy = "https://localproxy.localdomain",
        - no_proxy = ".our.local.domain,localhost",