Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start Docker containers on boot, managed with Ansible (Tower)

Tags:

docker

ansible

Currently we use the combination of Ansible + Ansible Tower to deploy and run our applications in Docker containers.

However, I was wondering how to automatically run the deployed containers after a system reboot. What would be the way to go here? The only solution we came up with is to automatically request the Tower callback URL of the application deployment playbook(s) on boot, but that seems suboptimal.

like image 251
Peter Avatar asked Aug 07 '15 06:08

Peter


1 Answers

You could use restart policies.

I do not know how exactly ansible creates containers. But usually you could add a parameter on command line like:

docker run --restart=always ...
like image 118
Henrik Sachse Avatar answered Sep 24 '22 23:09

Henrik Sachse