Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DOCKER_OPTS do not work in config file /etc/default/docker

I have changed /etc/default/docker with DOCKER_OPTS="-H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock" (docker version 1.4.1 in ubuntu 14.04), but it do not take any effect for me (not listening at port 2375). It seems that docker do not read this initial config file because I found export http_proxy enviroment do not work too.

Only sudo docker -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock -d works.

It really confused me!

like image 450
seanlook Avatar asked Jan 04 '15 07:01

seanlook


People also ask

Which is the default location of a config file when using Docker config?

The preferred method for configuring the Docker Engine on Windows is using a configuration file. The configuration file can be found at 'C:\ProgramData\Docker\config\daemon. json'. You can create this file if it doesn't already exist.

How do I change Docker daemon configuration?

To configure the Docker daemon using a JSON file, create a file at /etc/docker/daemon. json on Linux systems, or C:\ProgramData\docker\config\daemon. json on Windows. On MacOS go to the whale in the taskbar > Preferences > Daemon > Advanced.

What file is used to configure the Docker daemon?

To configure the Docker daemon using a JSON file, create a file at /etc/docker/daemon. json on Linux systems, or C:\ProgramData\docker\config\daemon. json on Windows. On MacOS go to the whale in the taskbar > Preferences > Daemon > Advanced .


1 Answers

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. Use the command sudo systemctl edit docker.service to open an override file for docker.service in a text editor.

  2. Add or modify the following lines, substituting your own values.

    [Service] ExecStart= ExecStart=/usr/bin/dockerd -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock 
  3. Save the file.

  4. Reload the systemctl configuration.

     $ sudo systemctl daemon-reload 
  5. Restart Docker:

     $ sudo systemctl restart docker.service 
  6. Check to see whether the change was honored by reviewing the output of netstat to confirm dockerd is listening on the configured port.

    $ sudo netstat -lntp | grep dockerd tcp        0      0 127.0.0.1:2375          0.0.0.0:*               LISTEN      3758/dockerd 
like image 57
Camilo Silva Avatar answered Oct 29 '22 17:10

Camilo Silva