Docker proxy and my struggles

Docker proxy and my struggles

·

2 min read

Table of contents

No heading

No headings in the article.

I recently joined a new organization and after getting around to spending a few days setting up my dev environment I sat down to do some actual work. My supervisor asked me to work on a project which requires Couchbase and I haven’t used it before. So I started procrastinating like a pro and fiddling around with what to do.

https://cdn-images-1.medium.com/max/800/1*lc8X3O42zZXwejzdm1U-EQ.gif

After wasting some valuable time I finally started reading the official documentation which needs Couchbase docker to run the server and here is where I got stuck. Docker was unable to pull the Couchbase image from the docker registry.

After scratching my head a bit I figured that the server I was working on is behind the notorious Corpo proxy

After figuring this out I reached out to my supervisor and asked for the proxies so that I can connect to the registry and after him handing that information over it was time to get to work again.

So the first thing I did was to check if there is a “docker.service.d” directory created in the path “/etc/systemd/system/” this server was Ubuntu 22.04 next I needed to create a “http-proxy.conf” file to save the proxies I got from my supervisor.

mkdir -p /etc/systemd/system/docker.service.d
vi /etc/systemd/system/docker.service.d/http-proxy.conf

In some cases you might need sudo so follow these instead:

sudo mkdir -p /etc/systemd/system/docker.service.d
sudo vi /etc/systemd/system/docker.service.d/http-proxy.conf

After the “http-proxy.conf” is created in the vi editor add the following lines to set up the proxy and work with the docker

[Service]
Environment="HTTP_PROXY=http://X.X.X.X:80"
Environment="HTTPS_PROXY=http://X.X.X.X:443"

Replace the X octets as per your proxy ip address.

Next to make the docker use this configuration we just added we will need to restart the docker daemon to reflect the changes. Follow the commands to restart the docker daemon:

sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl show --property=Environment docker
Environment=HTTP_PROXY=http://X.X.X.X:80 HTTPS_PROXY=http://X.X.X.X:443

“sudo systemctl show — property=Environment docker” shows the proxies we just configured it’s a way to check if you did it correctly or messed up anywhere 😵.

After I did this was able to pull the Couchbase image without any issues. So there’s our happy ending!

If you find this article helpful, please follow me this will encourage me to write on similar topics more 😀

If you want to support my efforts you can buy me a coffee here: