| Version 1 (modified by , 9 years ago) ( diff ) |
|---|
Docker HowTo Auto Start Containers On Reboot
An explanation for systemd as a process manager can be found at :
https://docs.docker.com/engine/admin/host_integration/
Once you are happy with your docker images and container, you must us systemd to restart them.
- Go to the directory :
/etc/systemd/system
This directory contains all .service files that are used to start docker containers.
- Check what docker services are enabled on start up
systemctl list-unit-files | grep docker
This will list out all the services that are enabled.
3a. To create a new service called *docker-[containername].service* :
sudo vi /etc/systemd/system/docker-redcap_5.7.0.service
add the contents :
[Unit]Description=Redcap 5.7.0 containerRequires=docker.serviceAfter=docker.service[Service]Restart=alwaysExecStart=/usr/bin/docker run -itd -p 81:80 lcbruit/redcap:v1ExecStop=/usr/bin/docker stop -t 2 lcbruit/redcap:v1[Install]WantedBy=default.target
3b. To amend
Run the following :
systemctl daemon-reloadsystemctl start docker-redcap_5.7.0.servicesystemctl enable docker-redcap_5.7.0.service
