modd icon indicating copy to clipboard operation
modd copied to clipboard

Daemon `docker run` fails to exit correctly

Open bartjkdp opened this issue 6 years ago • 3 comments

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?

bartjkdp avatar Nov 27 '19 12:11 bartjkdp

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

wader avatar Mar 22 '20 14:03 wader

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.

bartjkdp avatar Mar 22 '20 16:03 bartjkdp

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

wader avatar Mar 22 '20 20:03 wader