docker / docker/buildx

Feature: Allow docker build to stop processes with signal

Open
#1,863 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/enhancement
Dominant language
Go
Stars
4.5k
Forks
682
Avg merge
2d 14h
Merged PRs (30d)
29

Description

When a docker build is cancelled (either with CTRL+C or by the client losing connection to the daemon), allow the use of a SIGTERM (or other signal) to stop the running processes in the build container -- similar to how docker run does by default. This behavior does not need to be made default, but can be implemented as an option (which should also be settable from a docker-compose.yaml).

My use case is when my Dockerfile uses BuildKit cache mounts. With the current abrupt-kill method, the cache mount ends up having partially-written build products (e.g. C++ object files) with new timestamps, so make-based build systems encounter problems on the next attempt. If this feature is implemented, then GNU Make's .DELETE_ON_ERROR can respond to the signal by deleting the partially-written build products, so that next time that build step is repeated.

While this problem can happen when manual docker build runs are cancelled by the user, it is more problematic when it happens when docker-compose build --parallel (which is the default in Docker Compose V2) encounters any spurious problem in one of the image builds (e.g. timeout when downloading packages) and cancels the other image builds abruptly. (My current workaround is to disable Docker Compose V2.)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing cancellation in the docker build entry point and compare it with how docker run stops processes. Check how docker-compose build --parallel propagates cancellation and how BuildKit cache mounts are handled. Done means an opt-in signal can stop build processes gracefully and the option is available through docker-compose.yaml.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, docker-compose, go
Domain
build-system, devops
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.