Docker golang client, "always" as restart policy or ContainerWait for keeping a container running

Hi there,

If this is not the right place to post this question, please let me know! I am using the golang docker client/SDK to build a script which is responsible for starting up an application in a Docker container. I’d like that script to ensure that the application is always running, so if it crashes or something else kills it, I’d like the script (or Docker) to pick that up and restart the container.

Currently, I have that implemented using ContainerWait: https://godoc.org/github.com/docker/docker/client#Client.ContainerWait which has been successful.

However, I’m thinking about achieving this using a Restart Policy: https://docs.docker.com/engine/reference/run/#restart-policies---restart to move some of this logic out of my script and let Docker do the heavy lifting.

Does this seem like a better option, using the always restart policy? Just looking for general thoughts/suggestions here if anyone has insight/experience in this.

Thanks!

Hello @patrickdevivo

Seems like you never go an answer to this question, I am curious if you were able to accomplish the restart policy.

I have this container that for some reason exits suddenly I am not sure yet what is causing it but I would like to have the container restarted if it crashes or stops by itself.

Any suggestions?

Sincerely,