Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building the container behind a proxy #10

Closed
javixeneize opened this issue Mar 30, 2017 · 8 comments
Closed

Building the container behind a proxy #10

javixeneize opened this issue Mar 30, 2017 · 8 comments

Comments

@javixeneize
Copy link

Hi

One interesting question... How to build a container behind a proxy?

When running pip to install the dependencies, it cant resolve the host, so you need to add a proxy in the docker file

While using a ubuntu image, exporting the proxy is easy (ENV http_proxy .....), using alpine or python templates doesnt work

Any idea on how to solve this problem?

@jfloff
Copy link
Owner

jfloff commented Mar 30, 2017

Nice question. A quick google search gave me these discussions at the official Alpine docker image:

Do you think you could test this approach with a custom Dockerfile and provide feedback?

@jfloff
Copy link
Owner

jfloff commented Apr 19, 2017

Were you able to reach a solution @javixeneize ?

@javixeneize
Copy link
Author

Hi. Sorry, yes, it works fine configuring the proxy inside

Thanks

@jfloff
Copy link
Owner

jfloff commented Apr 25, 2017

Could you give some details on how you made it? Maybe write those instructions in the README and PR?

@javixeneize
Copy link
Author

javixeneize commented Apr 25, 2017 via email

@gbarco
Copy link

gbarco commented Jul 5, 2017

I would like to reopen threads like this one but requiring an answer that allows another person to run the same image without modifying and rebuilding from Dockerfile.

ENV in Dockerfile is so local, hacky and non portable it cripples Docker to uselessness in corporations.
Also incomplete since I assume you also will need a proxy to get your base image.

I expect proxy on host talks or something level of conversation to reach a solution.

@jfloff
Copy link
Owner

jfloff commented Jul 5, 2017

I actually stumped on this the other day: use ARG during the build. More details here: https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables-build-arg

Taken from the link above: $ docker build --build-arg HTTP_PROXY=http://10.20.30.2:1234 .

I think this fits your scenario.

@Multihuntr
Copy link

Multihuntr commented Aug 18, 2017

I would like to second using the --build-arg flag instead of ENV in the Dockerfile. By setting the --build-arg correctly, you set the environment variable only for build time.
By setting the environment variables within the Dockerfile, you are saying that it will always have to use those proxy settings (it's not so easy to unset an environment variable in docker), even in a running container, or any derivative images.
I got caught by this one yesterday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants