Почему docker stop ждёт ровно 10 секунд и что при этом теряет Python-воркер

habrahabr.ru · world
Full story

A Python worker container does not stop immediately; docker stop waits exactly ten seconds before it goes down. Docker spends that time waiting for the process to react to SIGTERM, but the process does not respond to it. The explanation ties this to PID 1 and a shell script used in ENTRYPOINT, and it examines what init: true can and cannot fix. It also presents a short asyncio worker template that finishes the current batch of data and exits on its own.

Удалить Контейнер с Python-воркером останавливается не сразу, а ровно через десять секунд. Docker всё это время ждёт, пока процесс отреагирует на SIGTERM, а тот его не слышит. Разбираю, почему так выходит с PID 1 и shell-скриптом в ENTRYPOINT, чем помогает и чем не помогает init: true, и показываю короткий шаблон asyncio-воркера, который дописывает текущую пачку данных и выходит сам. Читать далее

Read full article → Compare