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

httpProxy support #971

Open
zerkms opened this issue Apr 30, 2019 · 10 comments
Open

httpProxy support #971

zerkms opened this issue Apr 30, 2019 · 10 comments

Comments

@zerkms
Copy link

zerkms commented Apr 30, 2019

I'm running docker in a network with http proxy which is configured to be used in docker using proxies.default.httpProxy configuration directive.

It works fine with the default docker.

When I enable buildkit the networking operations fails with

 > [2/2] RUN apt update && apt install -y --no-install-recommends zip:
#7 0.383 
#7 0.383 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
#7 0.383 
#7 0.657 Err:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
#7 0.657   Could not resolve 'cache.org.tld'
#7 0.913 Err:2 http://archive.ubuntu.com/ubuntu bionic InRelease
#7 0.913   Could not resolve 'cache.org.tld'
#7 0.913 Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
#7 0.913   Could not resolve 'cache.org.tld'
#7 0.913 Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
#7 0.913   Could not resolve 'cache.org.tld'
#7 0.921 Reading package lists...

cache.org.tld' (redacted) is a valid hostname, resolvable by LAN DNS.

I tried to specify dns servers additionally in the /etc/docker/daemon.json, it does not change the outcome though.

A Dockerfile for the output above:

# syntax = docker/dockerfile:1.0-experimental
FROM ubuntu:bionic as base

RUN apt update && apt install -y --no-install-recommends zip

Is it

@Xuanwo
Copy link

Xuanwo commented Aug 30, 2019

Yes, we do need httpProxy support in build.

@nichoio
Copy link

nichoio commented Mar 16, 2021

Are there any news on this? I'm wondering if proxies set under /home/user/.docker/.dockerconfigjson or /home/user/.docker/config.json are applied. I'm using BuildKit within moby/buildkit:v0.8.2-rootless image.

@Xuanwo
Copy link

Xuanwo commented Mar 16, 2021

@rappertomate Please considering use podman instead.

@nichoio
Copy link

nichoio commented Mar 16, 2021

Nevermind, i figured it out.
Env variables http_proxy and https_proxy if applicable have to be set. buildkitd as well as buildctl (!) must have access to these vars.
Confusion stems from the fact that $DOCKER_CONFIG/config.json is processed to apply auths when pushing images, whereas proxies settings inside config.json are ignored it seems.
This should be stated more clearly. Maybe something that could be added to the docs @AkihiroSuda (i offer to do it)?
I'm also curious if there's any specific motivation behind the way proxy is handled as it is.

@florian0410
Copy link

florian0410 commented Aug 30, 2021

How did you give access to thehttp_proxy https_proxy vars for buildkit in the end ? @nichoio

@florian0410
Copy link

florian0410 commented Aug 30, 2021

Found it ! Just add --opt build-arg:myvar=myvar

Here is my resulting code in my case

      buildctl-daemonless.sh build
      --frontend dockerfile.v0
      --local context=.
      --local dockerfile=.
      --output type=image,name=${DOCKER_IMAGE_NAME}:${BUILD_VERSION},push=${ECR_PUSH}
      ${BUILDKITD_EXTRA_ARGS}
      --opt build-arg:http_proxy=${http_proxy}
      --opt build-arg:https_proxy=${https_proxy}
      --opt build-arg:HTTP_PROXY=${HTTP_PROXY}
      --opt build-arg:HTTPS_PROXY=${HTTPS_PROXY}
      --opt build-arg:no_proxy=${no_proxy}
      --opt build-arg:NO_PROXY=${NO_PROXY} 

Thank you for opening this issue it helps me to realize this proxy issue.

@rranjan3
Copy link

rranjan3 commented Aug 1, 2022

Found it ! Just add --opt build-arg:myvar=myvar

Here is my resulting code in my case

      buildctl-daemonless.sh build
      --frontend dockerfile.v0
      --local context=.
      --local dockerfile=.
      --output type=image,name=${DOCKER_IMAGE_NAME}:${BUILD_VERSION},push=${ECR_PUSH}
      ${BUILDKITD_EXTRA_ARGS}
      --opt build-arg:http_proxy=${http_proxy}
      --opt build-arg:https_proxy=${https_proxy}
      --opt build-arg:HTTP_PROXY=${HTTP_PROXY}
      --opt build-arg:HTTPS_PROXY=${HTTPS_PROXY}
      --opt build-arg:no_proxy=${no_proxy}
      --opt build-arg:NO_PROXY=${NO_PROXY} 

Thank you for opening this issue it helps me to realize this proxy issue.

I do not see it working even after I set these options.

sudo buildctl build 
--frontend dockerfile.v0 
--opt build-arg:http_proxy=${http_proxy} 
--opt build-arg:https_proxy=${https_proxy} 
--opt build-arg:no_proxy=${no_proxy} 
--local context=. 
--local dockerfile=. 
--output type=image,name=docker.io/username/image,push=false

@PaulSchweizer
Copy link

I also could not get this to work yet. My solution now is to pull all the required images before I run a build. Not elegant maybe but it's simple and it works, at least for me.

@elouanKeryell-Even
Copy link

I think apt does not support proxy configuration through environment variables, you have to modify apt files (like /etc/apt/apt.conf), see here: https://askubuntu.com/a/257296/412393

Not a docker problem IMO, it has more to do with apt

@shalashik
Copy link

I think apt does not support proxy configuration through environment variables

apt do support proxy configuration through environment variables

If no one of the above settings is specified, http_proxy environment variable will be used.

I agree with @nichoio confusion regarding the .docker/config.json file which is partially processed for auth settings, but ignored for proxy configuration.

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

No branches or pull requests

9 participants