I want to be able to run node inside a docker stop <container> container, and then be able to run docker stop <container> . This should stop the SIGTERM container, not the timing, and make SIGKILL . Unfortunately, I seem to be missing out on something, and the information I found seems to contradict other bits.
Here is the docker test file:
FROM ubuntu:14.04 RUN apt-get update && apt-get install -y curl RUN curl -sSL http://nodejs.org/dist/v0.11.14/node-v0.11.14-linux-x64.tar.gz | tar -xzf - ADD test.js / ENTRYPOINT ["/node-v0.11.14-linux-x64/bin/node", "/test.js"]
Here is the test.js mentioned in the Docker file:
var http = require('http'); var server = http.createServer(function (req, res) { console.log('exiting'); process.exit(0); }).listen(3333, function (err) { console.log('pid is ' + process.pid) });
I will build it like this:
$ docker build -t test .
I run it like this:
$ docker run --name test -p 3333:3333 -d test
Then I run:
$ docker stop test
After that, SIGTERM does not seem to work, causing it to time out after 10 seconds and then die.
I found that if I ran the node task via sh -c , then I can kill it with ^C from the interactive container ( -it ), but I still can't get docker stop Work. This contradicts the comments I read saying sh does not transmit a signal, but may agree with the other comments I read saying PID 1 does not receive SIGTERM (since it started with sh , this will be PID 2).
The ultimate goal is to be able to run docker start -a ... in the upstart job and be able to stop the service and actually exit the container.