moby: 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. It seems that docker do not read this initital 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!
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 25
- Comments: 56 (23 by maintainers)
Commits related to this issue
- Systemd init script should support DOCKER_OPTS See #9889 (specifically, [here](#9889 (comment)). The systemd daemon should support `DOCKER_OPTS` the same as upstart and sysv do. This commit is copie... — committed to mattelacchiato/docker by deleted user 9 years ago
- Systemd init script should support DOCKER_OPTS See #9889 (specifically, [here](#9889 (comment)). The systemd daemon should support `DOCKER_OPTS` the same as upstart and sysv do. This commit is copie... — committed to mattelacchiato/docker by deleted user 9 years ago
- fix docker config see https://github.com/docker/docker/issues/9889 huge thx to @resouer this needs still lots of cleanup but now completely works — committed to guybrush/k8s by deleted user 9 years ago
I’ve also encountered this problem (Debian Jessie 8.0, lxc-docker=1.6.2). After a look around at the configuration files in
/lib/systemd/system/
, it seems that the Docker configuration file (/lib/systemd/system/docker.service
) is not using/etc/default/docker
at all. 😦 The problem is solved by adding anEnvironmentFile
directive and modifying the command line to include the options from the file, e.g.I edited
/lib/systemd/system/docker.service
to look like the above, ransystemctl daemon-reload
, and then restarted the Docker service. This time, it properly launched with the options set inDOCKER_OPTS
in my/etc/default/docker
.Again, I’m on Debian Jessie 8.0 with lxc-docker=1.6.2, so YMMV.
@zepalmer, as the latest version of the documentation suggests (http://docs.master.dockerproject.org/articles/systemd/), the proper way to edit systemd service file is to create a file in
/etc/systemd/system/docker.service.d/<something>.conf
and only override the directives you need. The file in/lib/systemd/system/docker.service
is “reserved” for the package vendor.Using
/etc/docker/daemon.json
instead of/etc/default/docker
solved my issue! This comments for those who scrolls to the last post 👅@carloscds Don’t use
/etc/default/docker
. It’s used only by upstart, which is not used by Ubuntu since 16.04.Use
/etc/docker/daemon.json
, which is documented here: https://docs.docker.com/engine/reference/commandline/dockerd/#/linux-configuration-fileThis tripped me up a lot on Ubuntu 15.04 using Docker 1.8.0 experimental via the shell script install process. My assumption is the apt repository package does not provide a proper docker systemd unit file yet?
I ended up having to do a double ExecStart in my override file to clear the original else it would complain about two ExecStart’s on a oneshot.
I.e. in /etc/systemd/system/docker.service.d/docker.conf
If you use options that need expansion, e.g.:
DOCKER_OPTS="-g $(readlink -f /var/lib/docker)"
then this might help:Correct, the
/etc/default/docker
file is only used on systems using “upstart” and “SysVInit”, not on systems using systemd.This is also mentioned at the top of the file; https://github.com/docker/docker/blob/44fe8cbbd174b5d85d4a063ed270f6b9d2279b70/contrib/init/sysvinit-debian/docker.default#L1
You don’t define “DOCKER_OPTS”. In the old upstart config this is essentially what was happening:
DOCKER_OPTS
was not some special env var that Docker uses, it’s just set in one file and consumed by the init script in another file and inserted as an inline argument to the docker command./etc/docker/daemon.json
is the hard-coded default location for daemon configuration in Docker. To do the equivalent config as above you would put this in/etc/docker/daemon.json
:When docker starts, it reads this file and loads the configuration.
@carloscds did you take the time to read the discussion above before posting your question?
( I was initially looking for how to add
DOCKER_OPTS="--iptables=false"
)Sum-up for
Ubuntu 18.04
/Docker Server Version: 20.10.6
/etc/docker/daemon.json
@eric-tucker it helps for people that arrive on these issues through Google search, and may not be aware of the way things work.
Having gone down this road twice here’s my take for Debian Jessie:
Debian GNU/Linux 8 (jessie) / Docker version 1.12.3
vi /lib/systemd/system/docker.service
Change this line:
systemctl daemon-reload
service docker restart
Check it
docker info
Would be great if /etc/default/docker file wasn’t installed on systemd setups.
@thaJeztah That link fixed my issue too. I could clearly see that adding things to /etc/sysconfig/docker was not doing anything but I wasn’t really sure the best way to fix it.
Is there anyone I could notify to let them know the docs are wrong on this page: https://docs.docker.com/engine/articles/configuring/
Or at least put in a link for systemd (Red Hat) installs so others can figure it out faster: http://docs.docker.com/engine/articles/systemd/#custom-docker-daemon-options
@mattelacchiato no they were not. systemd has a built-in method called ‘drop-ins’ to handle customizing unit files.
https://coreos.com/os/docs/latest/using-systemd-drop-in-units.html