Changes between Initial Version and Version 1 of Docker HowTo Auto Start Containers On Reboot


Ignore:
Timestamp:
10/06/16 14:46:14 (8 years ago)
Author:
saj.issa
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Docker HowTo Auto Start Containers On Reboot

    v1 v1  
     1= Docker HowTo Auto Start Containers On Reboot
     2
     3An explanation for systemd as a process manager can be found at :
     4
     5   {{{https://docs.docker.com/engine/admin/host_integration/}}}
     6
     7Once you are happy with your docker images and container, you must us systemd to restart them.
     8
     91. Go to the directory :
     10
     11   {{{/etc/systemd/system}}}
     12
     13This directory contains all .service files that are used to start docker containers.
     14
     152. Check what docker services are enabled on start up
     16
     17   {{{systemctl list-unit-files | grep docker}}}
     18
     19This will list out all the services that are enabled.
     20
     213a. To create a new service called *docker-[containername].service* :
     22
     23   {{{sudo vi /etc/systemd/system/docker-redcap_5.7.0.service}}}
     24
     25add the contents :
     26
     27   {{{[Unit]}}}
     28   {{{Description=Redcap 5.7.0 container}}}
     29   {{{Requires=docker.service}}}
     30   {{{After=docker.service}}}
     31   {{{ }}}
     32   {{{[Service]}}}
     33   {{{Restart=always}}}
     34   {{{ExecStart=/usr/bin/docker run -itd -p 81:80 lcbruit/redcap:v1}}}
     35   {{{ExecStop=/usr/bin/docker stop -t 2 lcbruit/redcap:v1}}}
     36   {{{ }}}
     37   {{{[Install]}}}
     38   {{{WantedBy=default.target}}}
     39
     403b. To amend
     41
     42Run the following :
     43
     44   {{{systemctl daemon-reload}}}
     45   {{{systemctl start docker-redcap_5.7.0.service}}}
     46   {{{systemctl enable docker-redcap_5.7.0.service}}}