How to ensure a Docker container starts and stays running on a production server? How to ensure a Docker container starts and stays running on a production server? docker docker

How to ensure a Docker container starts and stays running on a production server?


With --restart=always you only need to execute docker run once. Docker service will take care about restart after that. So just execute such command once:

docker run -d --restart=always --name=container-name image-name command

and docker will restart container after container process stops and after reboot.