I'm creating a docker service that executes a command to start a program, but the problem is the service keeps terminating, because once the command to start completes, docker thinks it's done and terminates and starts it again. I want to change this behaviour so that the docker service runs, completes its command, then stays running forever after its command is completed.
How do I do this? I know you can use the -td
flag to do this with a plain old "docker run" but how do I do this with docker stack using a compose file?
EDIT: I'm attempting to append a "sleep infinity" command to the end of the command like this:
FROM ubuntu:16.04
ADD <redacted> /opt/<redacted>
CMD "/opt/<redacted>/start.sh; sleep infinity"
Running with docker stack deploy
results in:
/bin/sh: 1: /opt/<redacted>/start.sh; sleep infinity: not found