Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting Docker-Engine on boot

When I restart my host, I want my docker engine to start on boot.

Is this possible? Can anyone point me in right direction ?

My OS is RHEL 7.3 and my /usr/lib/systemd/system/docker.service fiel looks like:

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target firewalld.service

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
Restart=always
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process

[Install]
WantedBy=multi-user.target
like image 286
Akki Avatar asked Mar 27 '17 05:03

Akki


People also ask

Does docker start on startup?

Docker provides restart policies to control whether your containers start automatically when they exit, or when Docker restarts. Restart policies ensure that linked containers are started in the correct order. Docker recommends that you use restart policies, and avoid using process managers to start containers.


1 Answers

Yes. You can use this command to enable automatic start of the docker service after startup:

 sudo systemctl enable /usr/lib/systemd/system/docker.service
like image 94
Arash Avatar answered Oct 13 '22 18:10

Arash