Docker Community Forums

Share and learn in the Docker community.

Setting DOCKER_OPTS Ubuntu w/SystemD

docker

(Ronald Petty) #1

Hello,

I am unable to find an example of DOCKER_OPTS (ex. -H) being set for Ubuntu 16.04.1 (which uses SystemD.) The documentation here mentions using a Unit file.

I see other examples where people set docker.service. I tried both approaches and have not succeeded (did systemctl daemon-reload and docker reload.)

I am unclear about all the ways to use SystemD. Specifically, I was trying:

sudo vi /etc/systemd/system/docker.service.d/docker-opts.conf

[Service]
Environment=‘DOCKER_OPTS=-H tcp://127.0.0.1:4243’

user@ubuntu:~$ sudo systemctl daemon-reload
user@ubuntu:~$ systemctl reload docker
user@ubuntu:~$ systemctl show --property=Environment docker
Environment=DOCKER_OPTS=-H\x20tcp://127.0.0.1:4243
user@ubuntu:~$ ps wuxa | grep docker
root       8292  0.0  1.0 484720 40752 ?        Ssl  10:31   0:08 /usr/bin/dockerd -H fd://
root       8299  0.0  0.2 209564 10416 ?        Ssl  10:31   0:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --runtime docker-runc
user

Notice no -H set in ‘ps’. Also, in the systemctl show output, there is backslash x ‘\x’ for a space. I have not resolved that.

The link states to not touch docker.service and use unit files. I thought I was doing that, but I must be missing a step / idea.

Thanks.