Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

RUN <process> can leave processes running in the background #247

@fabiokung

Description

@fabiokung

Some RUN instructions on Dockerfiles can leave processes running in the background (e.g. daemons). If these daemons are writting to files in the context dir, tar will fail with:

archive/tar: write too long

... when the layer is being snapshotted, because files were modified after the tar header was written.

One idea to prevent this is to execute RUN instructions in a nested PID namespace, and kill -9 its PID 1 before proceeding to the next instruction. Or perhaps a poor man's version of it with process groups to minimize the problem on environments that can't unshare a nested PID namespace.

It is easy to reproduce this when building Dockerfiles that use gradlew, which spawns a daemon by default, and is constantly writting to a log file inside the layer.

Metadata

Metadata

Assignees

Labels

kind/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions