Processing
 

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

04/01/2015 07:13#1

seanlook

Member

Joined at: 8 months ago

Post: 1

Thank: 0

Thanked: 0

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!

13/07/2015 13:42Top#2

Ross

Member

Joined at: 12 months ago

Post: 68

Thank: 0

Thanked: 0

See here for later versions of Debian/Ubuntu that use systemd.

This link explains how to correctly modify a systemd unit file to work with DOCKER_OPTS: https://github.com/docker/docker/issues/9889

Essentially you create a /etc/systemd/system/docker.service.d/docker.conf file and specify your overrides there.

I had to do something like the following in the aforementioned file to launch docker with the DOCKER_OPTS environment variable in a systemd environment:

[Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network.target docker.socket Requires=docker.socket  [Service] EnvironmentFile=-/etc/default/docker ExecStart= ExecStart=/usr/bin/docker -d $DOCKER_OPTS -H fd:// MountFlags=slave LimitNOFILE=1048576 LimitNPROC=1048576 LimitCORE=infinity  [Install] WantedBy=multi-user.target 

Current docker install process seems to neglect the systemd unit file.

28/05/2015 11:15Top#3

kuttifunk

Member

Joined at: 8 months ago

Post: 1

Thank: 0

Thanked: 0

I had the same issue.

Ubuntu 14.10 uses systemd instead of sysv-init/upstart. Maybe you should look into /lib/systemd/system/docker.service to change the options.

04/09/2015 20:42Top#4

cml.co

Member

Joined at: 8 months ago

Post: 1

Thank: 0

Thanked: 0

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-reload systemctl restart docker 
14/01/2015 23:54Top#5

Daniel

Member

Joined at: 12 months ago

Post: 649

Thank: 0

Thanked: 0

I've just run into the "same" problem.

I noticed that all the options in the /etc/default/docker are actually commented out by default.

I removed the # in front of DOCKER_OPTS, restarted and it worked as intended.

I think previous docker versions (1.3) didn't have these options commented out by default, at least I can't remember having to remove the #-sign.

05/01/2015 09:45Top#6

Joined at: 8 months ago

Post: 6

Thank: 0

Thanked: 0

After checking docker source code (config.go and flags.go), I would say that the options you can pass in $DOCKER_OPTS are options for docker itself, and -H or --host is an option for docker daemon. As a workaround to solve your problem, you can edit the init script file you are using to include the -H option there. For example:

  • If you are using upstart init system, edit the file /etc/init/docker.conf changing the exec line with exec "$DOCKER" -H "tcp://127.0.0.1:2375" -H "unix:///var/run/docker.sock" -d $DOCKER_OPTS
  • If you are using sysvinit init system, edit the file /etc/init.d/docker changing the starting lines with something like:

start-stop-daemon --start --background \ --no-close \ --exec "$DOCKER" \ --pidfile "$DOCKER_SSD_PIDFILE" \ --make-pidfile \ -- \ -H "tcp://127.0.0.1:2375" \ -H "unix:///var/run/docker.sock" \ -d -p "$DOCKER_PIDFILE" \ $DOCKER_OPTS >> \ "$DOCKER_LOGFILE" 2>&1 log_end_msg $? ;;

29/06/2016 17:12Top#7

Forage

Member

Joined at: 12 months ago

Post: 4

Thank: 0

Thanked: 0

In reply to the systemd comments in combination with Ubuntu: Ubuntu 14.04 still uses Upstart, so the changes to /etc/default/docker should have had the desired effect. It isn't until 15.04 that Ubuntu started using systemd by default.

In case you have Ubuntu 15.04 or later and thus need to use systemd, or if you explicitly choose to use systemd before 15.04, the correct and simplest way to get the desired effect of the OP, a TCP socket, would be:

  1. Create the file /etc/systemd/system/docker.service.d/docker-tcp.conf
  2. Add the contents below
  3. Execute sudo systemctl daemon-reload
  4. Execute sudo systemctl restart docker

File contents:

[Service] ExecStart= ExecStart=/usr/bin/docker daemon --host=tcp://127.0.0.1:2375 
Similar articles

Non-interactive method for dpkg-reconfigure tzdata

5 years ago - Reply: 3 - Views: 143

monit is not able to read mongod.lock

2 years ago - Reply: 3 - Views: 141

Ubuntu: hadoop command not found

2 years ago - Reply: 4 - Views: 244

C# Mono Console.ReadLine quitting

4 years ago - Reply: 1 - Views: 87

linking jsoncpp on Ubuntu

2 years ago - Reply: 1 - Views: 6

Build artifacts over ssh jenkins - PHP

3 years ago - Reply: 1 - Views: 38

Can't load Metasploit after installation

3 years ago - Reply: 5 - Views: 222

Selenium FirefoxDriver in Headless get error

2 years ago - Reply: 1 - Views: 97

Unable to start MongoDB. ERROR: addr already in use

2 years ago - Reply: 2 - Views: 120

ZSH Agnoster Theme showing machine name

2 years ago - Reply: 4 - Views: 250

Unable to start firefox browser with jenkins user

2 years ago - Reply: 2 - Views: 113

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re