moby: Docker run works behind proxy, and Docker build does not
Output of docker version
:
Client:
Version: 1.12.0-rc4
API version: 1.24
Go version: go1.6.2
Git commit: e4a0dbc
Built: Wed Jul 13 03:28:51 2016
OS/Arch: windows/amd64
Experimental: true
Server:
Version: 1.12.0-rc4
API version: 1.24
Go version: go1.6.2
Git commit: e4a0dbc
Built: Wed Jul 13 03:28:51 2016
OS/Arch: linux/amd64
Experimental: true
Output of docker info
:
Containers: 14
Running: 0
Paused: 0
Stopped: 14
Images: 11
Server Version: 1.12.0-rc4
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 55
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.4.15-moby
Operating System: Alpine Linux v3.4
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.459 GiB
Name: moby
ID: 6NAS:3AQW:EXQJ:5S6Y:OHL7:6V2Y:IKMK:ZDI6:7BSA:QO7E:3L7S:EEEG
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Http Proxy: 10.0.75.1:7777
Https Proxy: 10.0.75.1:7777
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
127.0.0.0/8
Additional environment details (AWS, VirtualBox, physical, etc.):
Windows 10 Pro - Hyper-V Dell Latitude 3540
Steps to reproduce the issue:
- docker run -it ruby bash
- Configure http_proxy and https_proxy env variables
- execute apt-get update (it should run fine)
part that don’t work 4. create a Dockerfile with this content
FROM ruby:latest
RUN apt-get update -qq && apt-get install -y build-essential libmysqlclient-dev nodejs
- docker build .
Describe the results you received:
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM ruby:latest
---> e4b689e9dc8b
Step 2 : MAINTAINER Juliano Nunes
---> Using cache
---> 28ba78d36e99
Step 3 : RUN apt-get update -qq && apt-get install -y build-essential libmysqlclient-dev nodejs
---> Running in 9d1f43f218e9
W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie/InRelease
W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie-updates/InRelease
W: Failed to fetch http://security.debian.org/dists/jessie/updates/InRelease
W: Failed to fetch http://security.debian.org/dists/jessie/updates/Release.gpg Could not resolve 'security.debian.org'
W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie/Release.gpg Could not resolve 'httpredir.debian.org'
W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie-updates/Release.gpg Could not resolve 'httpredir.deb
ian.org'
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 build-essential
E: Unable to locate package nodejs
The command '/bin/sh -c apt-get update -qq && apt-get install -y build-essential libmysqlclient-dev nodejs' returned a
non-zero code: 100
Describe the results you expected:
It should run apt-get update/install and build the image.
Additional information you deem important (e.g. issue happens only occasionally):
- I have set in my Windows host the environment variables HTTP_PROXY and HTTPS_PROXY to make tools like GIT work behind a proxy.
- My company uses a proxy with NTLM authentication, then I use Fiddler as a tunnel (Internet Options is set to use 127.0.0.1:7777 as the proxy)
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 16
- Comments: 62 (21 by maintainers)
What helped in my case was setting up
HTTP_PROXY, http_proxy, HTTPS_PROXY, https_proxy
in docker file (I build my image form a file not repository) and setting upin
/etc/systemd/system/docker.service.d/http-proxy.conf
and then running
I do not know if that is of a matter here, but I used proxy server IP addresses in docker file and domain names in docker file.
To solve the problem with curl in docker build, I added the following inside the Dockerfile:
Note that the ENV statement is BEFORE the RUN statement.
and in order to make the docker daemon able to access the internet (I use kitematic with boot2docker), I added the following into /var/lib/boot2docker/profile :
@julianonunes You need to set
docker build --build-arg HTTP_PROXY=foo
Thanks to user by the name bpattewar.
His way of resolution worked for me(cut-paste below)
I colud solve it by setting http_proxy by using ip address of proxy server and not the url. My friend told reason for this is most of the images are by default set to use googles DNS server to resolve the url address. and thats why using url address for http_proxy fails.
Hi guys, I’m using a workaround to avoid this problem. I edited my
~/.bash_profile
and added these lines to create an alias todocker build
:Then now I use
docker_build --other-options .
to build my images.I hope this helps somebody. 😄
Quotes are probably unnecessary, they are just precaution. Variable names (http_/https_proxy) should be in the lower case and are case-sensitive.
docker build --build-arg "..."
works against my company’s proxy (squid) for building at least debian based images. As each docker build step is done by making-committing-destroying intermediate container it cannot inherit any variables from system (if it did, it would make builds non-portable).Hi, I don’t know the cause but just being outside the office network makes it work. Incase it is an option for anyone to run it being outside your office network.
I colud solve it by setting http_proxy by using ip address of proxy server and not the url. My friend told reason for this is most of the images are by default set to use googles DNS server to resolve the url address. and thats why using url address for http_proxy fails.
Would you please try, if you did not already,
docker build --build-arg http_proxy="http://10.0.75.1:7777"
?Right, so the problem likely is that the default
wget
in Alpine is in factbusybox
; here you can see that it’s a symlink to busybox:You can try installing an actual
wget
in alpine to see if that issue was fixed (the busybox version will get replaced with an actualwget
binary);If the proxy works correctly with the actual
wget
, then it’s likely busyboxI’m also experiencing this issue- setting the http_proxy build-arg to the ip address as suggested above does not fix the issue for me.
I have an added complication of having a proxy that requires authentication. I’ve tried qualifying the hostname and ip address of the proxy with the credentials (e.g.
<username>:<password>@<proxy_address>:<proxy_port>
), but to no avail.I’m using windows 10 and the ubuntu shell. I’m able to pull docker images successfully, but cannot build for the reasons described above (specifically, fetches to the alpine download page fail) . Any advice or support would be greatly appreciated!!
For me it fail to resolve www.abc-proxy.com , so I have put ipaddress instead of URL so it is working.
On Thu, Apr 27, 2017 at 5:43 PM, Brian Goff notifications@github.com wrote:
The issue is that even we give proxy by HTTP_PROXY , docker container try to resolves it using DNS entries which are set inside docker container. Because of DNS entries in container are values of public domain server and not from the corporate DNS server entries, it fails to resolve it. Is there a way that you allow to configure DNS entry along with http_proxy value
On Thu, Apr 27, 2017 at 7:48 AM, Brian Goff notifications@github.com wrote:
Ok, it seems like setting up “DOCKER_OPTS” in “/etc/default/docker” solved my issue:
DOCKER_OPTS="--dns <MY_CORPORATTE_DNS> --dns 8.8.8.8 --dns 8.8.4.4"
and restart the docker service. I can build on both Debian Jessie and Ubuntu 14.04 successfully.
Here are my docker versions:
Of course since I have proxies setup here is how I build my image:
sudo docker build --no-cache --build-arg HTTP_PROXY=$http_proxy --build-arg HTTPS_PROXY=$http_proxy --build-arg NO_PROXY=$no_proxy --build-arg http_proxy=$http_proxy --build-arg https_proxy=$http_proxy --build-arg no_proxy=$no_proxy --tag=<MY_TAG> .
For docker-compose up , you can set the http_proxy in docker-compose.yml ; Example:
version: ‘2’ services: parse-server: build: context: ./parse-server/ args: - http_proxy ports:
I’m on Debian Jessie and facing the same issue, while the same docker proxy setup works on CentOS 7.2.
I have the same problem and setting env variables globally or within the docker image did not help.
@julianonunes Thanks for reporting the issue. When you configure the HTTP/HTTPS proxies in Docker for Desktop GUI, multiple things happen:
docker run
command automagically getsHTTP_PROXY
,http_proxy
,HTTPS_PROXY
andhttps_proxy
added to the environnement variables.docker build
but it’s been forgotten. That’s the bug you are seeing.By the way, because of the magic env rewriting, you don’t need to set those env variables on you windows host.
ping @dave-tucker Can you confirm what I’m saying?
I’ve tried
docker build --build-arg HTTP_PROXY=http://127.0.0.1:7777
anddocker build --build-arg HTTP_PROXY=http://10.0.75.1:7777
.