Dockerfile STOPSIGNAL: configure the shutdown request
Read the recipe
FROM busybox:1.37STOPSIGNAL SIGINTCMD ["echo", "signal metadata demo"]A signal is a notification to a process. SIGTERM is the usual default when no other stop signal is configured. This short-lived recipe demonstrates configuration only: it does not test whether a running application catches SIGINT. The per-container --stop-signal override is set at creation. On stop, the engine allows a grace period before forceful termination if needed. A signal choice is not a substitute for testing application cleanup. The Engine targets the container main process. The grace period and eventual forced termination are distinct from an application responding successfully to the initial signal. The metadata-only recipe deliberately cannot demonstrate either.
Try it in a local lab
Manual lab only, not an interactive ByteMind execution. Use an approved disposable offline Linux VM, verified local Engine and Buildx docker driver. Check docker context show, docker version, docker buildx version and docker buildx ls. Confirm the local context/builder, reviewed preloaded busybox:1.37 with root default, no entrypoint, and required applets. Record actual digest/platform and use reviewed digest for repeatability. No network egress; --network none is not a complete builder egress control. Verify every bm-v08 image tag and container name in the commands is unused. Use synthetic data only. Run commands individually and stop on unexpected failure; remove only resources created by this lab after ownership checks. If cleanup cannot be confirmed, retire the disposable VM. Expected results are predictions, not observed output. Before contacting any Engine, resolve DOCKER_HOST, DOCKER_CONTEXT and CLI context overrides; also check BUILDX_BUILDER and any builder override. Confirm that the actual builder used by docker build is the approved local docker driver. Review the base configuration for inherited triggers, volumes, health checks, user, shell and required applets; stop if assumptions differ. Make a private working copy containing only the supplied synthetic files. An approved digest may require registry metadata resolution even when layers are present locally; if the offline builder cannot resolve it, stop and record the limitation. Record the actual base image ID, platform, builder version and output image ID; never substitute an unknown digest. Do not retry by enabling egress. Apply owner-approved time and resource budgets and retire the VM if cleanup is uncertain.
Open lab-fixtures/dockerfile-configuration/06-stopsignal/ from the extracted archive. Save the complete recipe and any additional files below in that directory.
docker build --load --network none -t bm-v08-stopsignal:lab .docker run --rm --pull=never --network none bm-v08-stopsignal:labdocker image inspect --format '{{.Config.StopSignal}}' bm-v08-stopsignal:labdocker create --pull=never --network none --name bm-v08-signal --stop-signal SIGTERM bm-v08-stopsignal:labdocker container inspect --format '{{.Config.StopSignal}}' bm-v08-signaldocker rm bm-v08-signalExpect SIGINT in image configuration and SIGTERM in the newly created container. The create command does not start it. No shutdown behavior is observed by this experiment.
Confirm the tag belongs to this lab and no container depends on it. Remove it without forcing deletion. Build cache may remain until VM disposal. Record output and exit status before removing the exact lab tag. Recheck the tag against the recorded output image ID; a tag may have been reassigned.
Common mistake
Do not use SIGKILL as a routine graceful-stop signal. It cannot be caught for cleanup. The choice of initial signal also does not change what Ctrl+C means to a foreground process.
Manual practice
Explain why inspecting StopSignal is weaker evidence than observing a service finish an in-progress task and exit within its grace period. Describe the latter test without executing it.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Dockerfile STOPSIGNAL: configure the shutdown request — Knowledge check
Apply the configuration concept to a new image or container scenario.
What does STOPSIGNAL configure?
What overrides the image signal for a container?
Does metadata prove graceful shutdown?