Daemon `docker run` fails to exit correctly
I use the following configuration to spin up a Docker container as daemon, but modd fails to kill the container when modd is exited.
modd.conf
{
daemon +sigterm: docker run \
--rm \
-p 5556:5556 \
-v $(PWD)/dex.yaml:/config.yaml \
quay.io/dexidp/dex:v2.20.0 \
serve /config.yaml
}
When I run the process manually it responds to SIGTERM and kills it:
$ docker run \
--rm \
-p 5556:5556 \
-v $(PWD)/dex.yaml:/config.yaml \
quay.io/dexidp/dex:v2.20.0 \
serve /config.yaml &
[1] 8414
$ kill 8414
[1] + 8414 exit 2 docker run --rm -p 5556:5556 -v $(PWD)/dex.yaml:/config.yaml serve
I am using:
- modd 0.8
- OSX 10.15.1
Do you have any suggestions how I can further debug this issue?
Maybe could try exec docker run .... if the shell is not forwarding the signal to docker. Also could try set @shell = bash and use exec
Thanks a lot @wader. Just tried this, but unfortunately it does not work:
@shell = bash
{
daemon +sigterm: exec docker run \
--rm \
-p 5556:5556 \
-v $(PWD)/dex.yaml:/config.yaml \
quay.io/dexidp/dex:v2.20.0 \
serve /config.yaml
}
Pull request https://github.com/cortesi/modd/pull/79 fixes the problem, but I am not sure this is the right way to go for modd. I think Docker does not respond correctly to the kill signal.
Aha sorry not sure how i missed this was during exit, assumed it was about restarting on change. Yeah somethinh like your PR would make sense i guess, send signal wait for exit or timeout and kill