Docker daemon flags ignored Docker daemon flags ignored docker docker

Docker daemon flags ignored


Recommended Way Docker 17.xx +

There are a number of ways to configure the daemon flags and environment variables for your Docker daemon. The recommended way is to use the platform-independent daemon.json file, which is located in /etc/docker/ on Linux by default.

So, for configuring insecure registries, do the following:

  1. Set the following flag in the /etc/docker/daemon.json file:

    {    "insecure-registries": ["mydocker-registry.net:5000"]}
  2. Restart Docker

     $ sudo systemctl restart docker

Easier each time!


Previously Recommended Way with Docker 1.12

According to docker documentation, The recommended way to configure the daemon flags and environment variables for your Docker daemon is to use a systemd drop-in file.

So, for this specific case, do the following:

  1. Create a file called /etc/systemd/system/docker.service.d/private-registry.conf with the following content:

    If not exists, create directory /etc/systemd/system/docker.service.d

    [Service]ExecStart=ExecStart=/usr/bin/dockerd --insecure-registry mydocker-registry.net:5000
  2. Flush changes:

    $ sudo systemctl daemon-reload
  3. Restart Docker:

     $ sudo systemctl restart docker

Voila!


Not recommended way

Edit file /lib/systemd/system/docker.service

...[Service]ExecStart=/usr/bin/docker -d -H fd:// $DOCKER_OPTS...EnvironmentFile=-/etc/default/docker...

Then execute

systemctl daemon-reloadsystemctl restart docker

Verify that /etc/default/docker is loaded

ps auxwww | grep dockerroot      4989  0.8  0.1 265540 16608 ?        Ssl  10:37   0:00 /usr/bin/docker -d -H fd:// --insecure-registry 

That's it.


Things seem to have changed in Ubuntu 16.04 using docker 1.12.x. Based on the updated documentation

Add DOCKER_OPTS="-g /mnt/somewhere/else/docker/ --storage-driver=overlay2" to /etc/default/docker

Edit file /lib/systemd/system/docker.service

...[Service]ExecStart=/usr/bin/dockerd -H fd:// $DOCKER_OPTS...EnvironmentFile=-/etc/default/docker...

Then execute:

sudo systemctl daemon-reloadsudo systemctl restart docker


Systemd based systems do not read /etc/default configurations, you have to put those in /etc/systemd now, see also docker bug docker bug #12926

There is an official documentation on the Docker site now, refer to Control and configure Docker with systemd.

You should never directly hack the service files for configuration.

Tested and works on Arch and Debian based systems - I had to include the option to ignore any obsolete EnvironmentFile directives, though (see also linked Docker reference, but I didn't spot it at first and thought it was not needed):

-EnvironmentFile=/etc/default/dockerExecStart=ExecStart=/usr/bin/docker daemon ...