You have an unstable Docker container and need restart it automatically when it down.
Docker has useful parameter
--restart with three options:
no- do not restart container, default behavior
always- restart container on every shutting down
on-failure- restart container only if it exit with code != 0
So you should only add flag
--restart=always when starting container.
If you use docker-compose you can add line
Docker run command
Compose file reference