When running the docker image isolated with something like:
docker run --rm -p 4584:4584 -e SERVICES=secretsmanager localstack/localstack
it doesn't stop on Ctrl + C, and if you send a docker stop [container] it will timeout and docker will finally kill it since it doesn't act on neither SIGINT nor SIGTERM.
maybe it's possible to trap SIGINT in the docker-entrypoint.sh and do a graceful shutdown? My bash skills are a bit weak to actually know :)
Thanks for reporting @jishi - have you tried running with the -it flags enabled?
docker run -it --rm -p 4584:4584 -e SERVICES=secretsmanager localstack/localstack
In general, the recommended way to start LocalStack is using the pip package localstack. It sets all the required Docker flags for you. Example output on Mac OS:
$ localstack start
docker run -it -e DEFAULT_REGION="us-east-1" -e LOCALSTACK_HOSTNAME="localhost" -p 4510-4530:4510-4530 --rm --privileged --name localstack_main -p 8080:8080 -p 8081:8081 -p 443:443 -p 4567-4607:4567-4607 -v "/private/var/folders/n0/xq8l4cb94278hvzj00wzn4c40000gp/T/localstack:/tmp/localstack" -v "/var/run/docker.sock:/var/run/docker.sock" -e DOCKER_HOST="unix:///var/run/docker.sock" -e HOST_TMP_FOLDER="/private/var/folders/n0/xq8l4cb94278hvzj00wzn4c40000gp/T/localstack" "localstack/localstack"
...
Thank you for the prompt reply! Ah, my bad, it does actually catch SIGINT correctly when using -it flag.
However, it still doesn't work with external signals, like
docker kill -s INT [container] or docker stop [container]
Docker stop sends SIGTERM by default (IIRC) and will send a SIGKILL if the process doesn't respond within 10 seconds, which seems to always be the case.
I would find this useful for daemonizing the container in a CI environment when running my tests, although at least supporting Ctrl +C was my main problem to begin with.
If clean shutdown from a docker stop (and I guess this affects docker-compose stop as well) is irrelevant, you may close this issue.
Closing this issue, but please feel free to contribute a pull request if you manage to find a solution. Thanks!
Most helpful comment
Thank you for the prompt reply! Ah, my bad, it does actually catch SIGINT correctly when using
-itflag.However, it still doesn't work with external signals, like
docker kill -s INT [container]ordocker stop [container]Docker stop sends SIGTERM by default (IIRC) and will send a SIGKILL if the process doesn't respond within 10 seconds, which seems to always be the case.
I would find this useful for daemonizing the container in a CI environment when running my tests, although at least supporting Ctrl +C was my main problem to begin with.
If clean shutdown from a
docker stop(and I guess this affectsdocker-compose stopas well) is irrelevant, you may close this issue.