Skip to content

Systemctl

David Lee edited this page Jan 24, 2017 · 4 revisions

Systemctl Configuration

=======================

For RHEL 7+ distributions, install ‘docker-engine’ from the dockerproject repository. Older versions of docker-engine and docker-machine used different paths for the systemctl config files and when upgraded did not always convert cleanly from the older location.

Docker Yum Repo

Docker is changing very quickly, its important to keep up to date. Most linux distributions are behind on docker updates. Recommend using the Docker Repostory appropriate to your distribution.

Centos 7

Example of /etc/yum.repos.d/docker.conf

[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg

With the above in place install docker with yum install docker-engine

Docker startup

Configure Docker Daemon

Reference the full docs.

https://docs.docker.com/engine/admin/systemd/

RedHat 7 -

docker.conf

Locate your docker.conf file Run systemctl to get the current location of docker.conf Note: earlier versions of docker and docker-engine, and docker-machine placed the config file in /etc/ so you might have both. Use the one systemctl shows as the active configuation.

Note that the "Drop-In" will not exist on a clean install, only after configuring docker.

BEFORE

[root@z600 system]# systemctl status docker
docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset:disabled)
Active: active (running) since Sun 2017-01-15 11:01:39 EST; 5 days ago
Docs: https://docs.docker.com

AFTER

[root@z600 system]# systemctl status docker  
docker.service - Docker Application Container Engine  
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset:disabled)  
Drop-In: /etc/systemd/system/docker.service.d  
└─docker.conf  
Active: active (running) since Sun 2017-01-15 11:01:39 EST; 5 days ago  
Docs: https://docs.docker.com

There is an existing file you should not edit In this case its :

/usr/lib/systemd/system/docker.service

Instead use the 'drop in' feature of systemctl and add a new file to the dropin directory Consult systemctl to find what the directory is

may be :

/lib/systemd/system/docker.service.d
/usr/lib/systemd/system/docker.service.d
/etc/systemd/system/docker.service.d

You can call it anything, I suggest 'docker.conf'

Edit docker.conf, in this case its /etc/systemd/system/docker.service.d/docker.conf

The following is an example Make sure you have "ExecStart=" as the first so that it will overwrite the default.

Note: ExecStart is line wrapped for readability, it should be all on one line.

ExecStart=  
ExecStart=/usr/bin/dockerd
-H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock  
--storage-driver overlay2
--tlsverify --tlscacert /etc/docker/ca.pem
--tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem  
--label provider=generic
--bip=10.250.0.1/16

#  
MountFlags=slave
LimitNOFILE=1048576  
LimitNPROC=1048576  
LimitCORE=infinity  
Environment=

Explanation of flags

--bip=<subnet>

--tlsverify --tlscacert /etc/docker/ca.pem  
--tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem
Networking options

See Networking for details on choosing the right values

Storage drive

--storage-driver overlay2

See Storage for details