Skip to content

Please support SHELL even in OCI builds #6460

@amluto

Description

@amluto

Issue Description

If you try to build a Containerfile that contains a SHELL directive, the build fails with "SHELL is not supported for OCI image format". This is explicit logic in buildah, but I think it's misunderstanding the way that SHELL works in Docker, in BuildKit and in everything else compatible with them (including OCI tools!)

If I build this trivial Containerfile/Dockerfile:

FROM alpine:latest
RUN apk add --no-cache bash
SHELL ["/bin/bash", "-c"]
RUN if [[ "a" == "a" ]]; then true; fi

using BuildKit, it works fine. And I get an image that doesn't have a shell set, because it's OCI and that's not a thing. But that's not the point -- SHELL is part of the build process. Even the official Dockerfile reference makes no mention whatsoever of OCI in the SHELL documentation. And this usage of SHELL is very, very common.

I understand that the current behavior may represent a sort of principled stance, but it's a principle that makes writing Containerfiles unnecessarily awkward and that is not compatible with anything else.

See containers/podman#8477

The code is here:

b.Logger.Warnf("SHELL is not supported for OCI image format, %s will be ignored. Must use `docker` format", shell)

Steps to reproduce the issue

Steps to reproduce the issue

  1. Try to build the above Containerfile in the default OCI mode

Describe the results you received

buildah refuses to build it.

Describe the results you expected

It should work.

buildah version output

$ buildah version
Version:         1.33.7
Go Version:      go1.22.2
Image Spec:      1.1.0-rc.5
Runtime Spec:    1.1.0
CNI Spec:        1.0.0
libcni Version:  
image Version:   5.29.2
Git Commit:      
Built:           Wed Dec 31 16:00:00 1969
OS/Arch:         linux/amd64
BuildPlatform:   linux/amd64

buildah info output

$ buildah info
{
    "host": {
        "CgroupVersion": "v2",
        "Distribution": {
            "distribution": "ubuntu",
            "version": "24.04"
        },
        "MemFree": 1270116352,
        "MemTotal": 134898020352,
        "OCIRuntime": "crun",
        "SwapFree": 0,
        "SwapTotal": 0,
        "arch": "amd64",
        "cpus": 32,
        "hostname": "21a",
        "kernel": "6.8.0-52-generic",
        "os": "linux",
        "rootless": true,
        "uptime": "6288h 16m 40.84s (Approximately 262.00 days)",
        "variant": ""
    },
    "store": {
        "ContainerStore": {
            "number": 12
        },
        "GraphDriverName": "overlay",
        "GraphOptions": null,
        "GraphRoot": "/vol0/encrypted/home/luto/.local/share/containers/storage",
        "GraphStatus": {
            "Backing Filesystem": "zfs",
            "Native Overlay Diff": "true",
            "Supports d_type": "true",
            "Supports shifting": "false",
            "Supports volatile": "true",
            "Using metacopy": "false"
        },
        "ImageStore": {
            "number": 187
        },
        "RunRoot": "/run/user/1002/containers"
    }
}

Provide your storage.conf

N/A

Upstream Latest Release

No

Additional environment details

Additional environment details

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.stale-issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions