I have some containers that need to be started as services in a swarm cluster. The point is that the container will run a service at a certain time and after that it must be removed.
How do I remove a service after the container runs what it needs and stops?
The --restart-condition flag already helps me to run only once, but I still need it to be removed to be created again the next time.
# docker --version
Docker version 19.03.13, build 4484c46d9d
Update:
To work around this, after docker services create I run:
while docker service ps --filter "desired-state=Running" ${DOCKER_SERVICE} | grep ${DOCKER_SERVICE} >/dev/null 2>&1 ; do sleep 1; done &&
docker service rm ${DOCKER_SERVICE}
But I think this is not a best way
0 Answers