Docker

docker-compose can specify one or multiple yml files, also about config option.

docker-compose -f docker-compose-dev.yml up

specify yml file.

docker-compose -f docker-compose-base.yml -f docker-compose-dev.yml up

multiple -f can merge multiple yml file. Different parts will be merged, and for overlapped parts, later file will override former files.

docker-compose -f docker-compose-base.yml -f docker-compose-dev.yml config

docker-compose <...> config can display final config structure.

Why I cannot catch docker-compose down signal

I write a python code, to catch terminate signal,

import signal

signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGWINCH, signal_handler)
signal.signal(signal.SIGINT, signal_handler)

However I found using docker-compose down, the program cannot catch the signal. very confusing. then found this article.

copy:

https://www.evernote.com/l/AB1zfELghxNLSZXbqeBgkx_mbQAQFsGktd0/

Summary

  • Use the exec/JSON array form of ENTRYPOINT.

  • Use exec in shell entrypoints.

  • Don’t pipe your application’s output.

  • Avoid being PID 1.

  • Listen for SIGTERM or set STOPSIGNAL in your Dockerfile.

Most ignore part is exec one:

So instead of

do

Last updated

Was this helpful?