2

I am trying to run docker behind a proxy on a linux/ubuntu server machine. I have configured every proxy on the box (FTP/HTTPS/HTTP), I have also configured the Docker proxies mentioned here: https://docs.docker.com/config/daemon/systemd/#httphttps-proxy and https://stackoverflow.com/a/28093517/4261713

However, I have the docker service set to auto-start on machine boot, unless I log onto the machine and run sudo service docker restart those settings are ignored, and docker fails to use a proxy. This is all fine, we have a work around for local access, but I need to use this machine remotely using auto-builds/deployments etc. Therefore, the builds break without running that command.

What I have already tried:

  1. I have created the http-proxy.conf in /etc/systemd/system/docker.service.d and created the Environment variable there for the proxy.

  2. I have tried to modify the docker service init.d file by adding to the "DOCKER_OPTS" variable at the top using -e "HTTP_PROXY=http://addressofproxy:portofproxy" -e "HTTPS_PROXY=http://addressofproxy:portofproxy" However, this also has made no difference and I still need to restart the service after a reboot!

  3. I have also set/configured the client config in ~/.docker/config.json to have the proxies in.

Installation

Docker was installed using sudo apt-get install docker.io from command line, it was not built from source.

Host and Versions info:

Ubuntu Version (lsb_release -a)

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:       bionic 

DockerVersion (docker --version)

Docker version 18.06.1-ce, build e68fc7a

Installed Package (sudo apt list --installed | grep docker):

docker.io/bionic-updates,bionic-security,now 18.06.1-0ubuntu1.2~18.04.1 amd64
  • 1
    Is it possible the proxy only goes up after the service on docker? – Rui F Ribeiro Mar 5 at 14:18
  • No, its a corporate proxy in 'the cloud', so its always up. I can WGET/CURL successfully from the machine on boot but cant docker login until i restart the service – Chris Watts Mar 6 at 6:47
  • by default docker server itself will get launched on machine reboot ... if you are not seeing this behavior your docker install technique must have been non standard ... if so update your question explaining how you did docker install ... on a test box I use this to install docker ... curl -fsSL test.docker.com | sh ... which I can confirm works fine on ubuntu (16.04 + ) and debian 8 + 9 – Scott Stensland Mar 7 at 14:07
  • @ScottStensland I am on ubuntu server, so did sudo apt-get install docker (or docker.io).. let me update question – Chris Watts Mar 7 at 15:39
  • Looks at the set up of the docker service in /usr/lib/systemd/system/docker.service – Raman Sailopal Mar 7 at 16:05
0

I have a set of docker containers controlled by a docker-compose yaml file similar to below

version: '3'
services:

  nodejs-admin:
    image: ${GKE_APP_IMAGE_ADMIN}
    hostname: admin
    container_name: loud_admin
    restart: always
    ... more tags go here

in above I list all containers I need launched on reboot ... notice in above tag

restart: always

which tells docker to restart these containers on box reboot ... to bring all containers down issue

docker-compose  -f /somepath/docker-compose.yml down

to launch containers issue

docker-compose  -f /somepath/docker-compose.yml pull imageA  imageB  

docker-compose  -f /somepath/docker-compose.yml up -d 
  • thanks for that, but i mean the main Docker service (that runs the containers on the host machine) rather than the containers themselves. We are looking to use docker-compose for other tasks where this will be useful though so thanks! – Chris Watts Mar 7 at 9:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.