Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose build and http_proxy

I want to test ELK. It works fine BUt when I want to do a

docker-compose up

behind a proxy

docker-compose up --no-recreate 
Building kibana
Step 1 : FROM kibana:latest
 ---> 544887fbfa30
Step 2 : RUN apt-get update && apt-get install -y netcat
 ---> Running in 794342b9d807

It failed

W: Some index files failed to download. They have been ignored, or old ones used instead.

Is' OK with

docker build  --build-arg  http_proxy=http://proxy:3128  --build-arg https_proxy=http://proxy:3128 kibana

But when I redo a docker-compose up, il tries to re-build, and failed to pass through proxy

Any help ?

like image 212
toffd Avatar asked Jan 25 '16 10:01

toffd


People also ask

What is Http_proxy environment variable?

The https_proxy environment variable holds the hostname or IP address of your proxy server. https_proxy is a standard environment variable. Like any environment variable, the specific steps you use to set it depends on your operating system.

How configure Docker HTTP proxy?

On the Docker client, create or edit the file ~/. docker/config. json in the home directory of the user which starts containers. Add JSON such as the following, substituting the type of proxy with httpsProxy or ftpProxy if necessary, and substituting the address and port of the proxy server.

Do you need an HTTP proxy Docker?

A proxy is required when the server running Docker does not have direct access to the Internet. Configure the Docker daemon to use a proxy server to access images stored on the official Docker Hub Registry or 3rd-party registries.


1 Answers

You will need docker-compose 1.6.0-rc1 in order to pass the proxy to your build through docker-compose.
See commit 47e53b4 from PR 2653 for issue 2163.

Move all build related configuration into a build: section in the service.
Example:

web:
  build:
    context: .
    dockerfile: Dockerfile.name
    args:
       key: value

As mkjeldsen points out in the comments

If key should assume the value of an environment variable of the same name, value can be omitted (docker-compose ARGS):

Especially useful for https_proxy: if the envvar is unset or empty, the builder will not apply proxy, otherwise it will.

like image 87
VonC Avatar answered Sep 22 '22 14:09

VonC