There is a docker with several containers. After the reboot (or power outage) of the host, the docker does not start the containers.

    2 answers 2

    According to official documentation , this is not a bug, but a feature. Dock hands can be done with docker start -a . If you want it to self-create a rule in the initialization system of the host OS.

    Upstart :

     description "Redis container" author "Me" start on filesystem and started docker stop on runlevel [!2345] respawn script /usr/bin/docker start -a redis_server end script 

    Systemd :

     [Unit] Description=Redis container Requires=docker.service After=docker.service [Service] Restart=always ExecStart=/usr/bin/docker start -a redis_server ExecStop=/usr/bin/docker stop -t 2 redis_server [Install] WantedBy=local.target 

    Well, or you can docker start -a register in /etc/rc.local - but this is beyond good and evil.

    • These directives must be entered into /etc/systemd/system.conf? - Meiram Chuzhenbayev

    According to official documentation , when creating a container, you can set a restart policy with the --restart parameter, and the Docker daemon will restart the containers itself under certain conditions.

    • no does not restart, default
    • on-failure and on-failure:N restarts the container if its process ends with an error (return code is not 0), a maximum of N times (or permanently)
    • unless-stopped starts the container when the Docker daemon starts if the container was active (it was not unless-stopped before)
    • always restarts whether it was previously stopped or dropped.

    But this does not help much if the container is to be started only when a certain service is started on the host system. In this case, the order must be followed by a process that knows about this service.