Skip to content

fix: support SHELL during RUN commands in image build#6695

Open
aeijdenberg wants to merge 1 commit intocontainers:mainfrom
aeijdenberg:allowshellforruncommands
Open

fix: support SHELL during RUN commands in image build#6695
aeijdenberg wants to merge 1 commit intocontainers:mainfrom
aeijdenberg:allowshellforruncommands

Conversation

@aeijdenberg
Copy link
Contributor

Currently adding a SHELL instruction results in a WARN message, but then continues to build the image, using the incorrect shell (the default shell) if the output format is to OCI.

While the OCI spec doesn't allow persistence of the SHELL value, it also doesn't actually define the format of a Dockerfile/Containerfile, and the primary examples given in Docker documentation for use of SHELL is to affect subsequent RUN commands, which is a build time operation.

Since this is a build time operation, the final output format shouldn't cause a change in behaviour.

This removes the conditional that disables it, and adjusts the WARN message.

What type of PR is this?

/kind bug

I think it fixes a bug - because previously it would emit a WARN but then not actually fail, but instead use the wrong shell.

What this PR does / why we need it:

Better compatiblity with Dockerfiles.

How to verify it

See test in tests/bud.bats

Which issue(s) this PR fixes:

Fixes #6460.

Special notes for your reviewer:

Docker docs:
https://docs.docker.com/reference/dockerfile/#shell

There's some interesting and relevant discussion in:
opencontainers/image-spec#1248 (comment)

Does this PR introduce a user-facing change?

`SHELL` instructions will now affect subsequent `RUN` instructions in a `Containerfile`, even when the format is OCI

Currently adding a SHELL instruction results in a WARN message, but then
continues to build the image, using the incorrect shell (the default
shell) if the output format is to OCI.

While the OCI spec doesn't allow persistence of the SHELL value, it also
doesn't actually define the format of a Dockerfile/Containerfile, and
the primary examples given in Docker documentation for use of SHELL is to
affect subsequent RUN commands, which is a build time operation.

Since this is a build time operation, the final output format shouldn't
cause a change in behaviour.

This removes the conditional that disables it, and adjusts the WARN
message.

Signed-off-by: Adam Eijdenberg <adam@continusec.com>
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Feb 20, 2026
Copy link
Member

@nalind nalind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please support SHELL even in OCI builds

2 participants