Damon
Damon

Reputation: 4484

Docker: Using MacOS, how can I pull CENTOS behind a proxy?

To begin with, I am behind a corporate proxy. I'm using docker 1.12.0

Using OSX, my .bash_profile looks like this:

export http_proxy='http://server-ip:port/'
export https_proxy='http://server-ip:port/'
export no_proxy='localhost,0.0.0.0,127.0.0.1'

What puzzles me is that I am able to pull the ubuntu image without any problems.

docker pull ubuntu:latest

When I attempt to pull centos I get the following error:

docker pull centos:latest
latest: Pulling from library/centos
8d30e94188e7: Pulling fs layer 

dial tcp i/o timeout

I've ready through this post about centos connection issues. I believe I have followed the suggested answers but still no luck.

I am able to pull the image without any problems on my personal machine, so I know it must be something with the proxy. Any suggestions are greatly appreciated!

Upvotes: 0

Views: 2214

Answers (3)

Damon
Damon

Reputation: 4484

This is painfully obvious now, and instead of turning to the internet first, I should have simply checked preference options.

In Docker for Mac, v1.12.0 once installed, click on the docker icon in the toolbar (upper right corner next to the clock) and choose "Preferences".

Under the "Advanced" tab, you can enter proxy information.

Thank you BMitch for your time, I appreciate it!

Upvotes: 1

BMitch
BMitch

Reputation: 263627

Setting the environment variables in your .bashrc will update the network config for any commands you run as the user. However, Docker is designed as a client/server app, and the image pulls are run from the server (dockerd). Docker has docs on how to configure systemd with a proxy that should solve your issue. In brief, you need to adjust the following:

sudo -s
mkdir /etc/systemd/system/docker.service.d
cat >/etc/systemd/system/docker.service.d/http-proxy.conf <<EOF
[Service]
Environment="HTTP_PROXY=http://server-ip:port/"
EOF
systemctl daemon-reload
systemctl restart docker
exit

If you don't have systemd installed, you should be able to edit /etc/default/docker. The entry you need to add there is export http_proxy="http://server-ip:port/".

Lastly, I'm now seeing that you're on MacOS (the question about CentOS is a red herring since I'm sure you can't pull any image and you're not actually running CentOS). In boot2docker, you have the following procedure:

boot2docker ssh
sudo vi /var/lib/boot2docker/profile 
# include your "export HTTP_PROXY=http://server-ip:port/" here
sudo /etc/init.d/docker restart
exit

Upvotes: 0

Karthik427
Karthik427

Reputation: 11

Please pull and save image on your laptop. Transfer the image to the server with no internet connection and use docker load.

Hope this works.

Upvotes: 0

Related Questions