I need to launch a docker-compose on an ubuntu-server every time it is rebooted.
I have tried to create a crontab like this:
@reboot docker-compose -f /home/user/docker-compose/docker-compose.yml up -d
But when I restart it this has not given results, any ideas?
The only thing you need for it to restart itself is
restart: always
in the yml .So if you
docker-compose.yml
are this:It is enough for you to put it
restart: always
in the container :Then, in the folder, you do
docker-compose up -d
(so that it boots as a separate process) and voila, every time Ubuntu restarts , it boots the container .A good tip is to put it like:
Thus, I limit the attempts to upload the container to 5 times in case of failures. If you leave it on, it
always
will try to upload the container forever and that can mean a consumption of resources that degrades your system.