redhat-actions / buildah-build

GitHub Action to use 'buildah' to build a container image.
https://github.com/marketplace/actions/buildah-build
MIT License
142 stars 35 forks source link

[BUG] Buildah-build fails when previously ran as root #119

Closed np22-jpg closed 1 year ago

np22-jpg commented 1 year ago

Version

redhat-actions/buildah-build@v2

Describe the bug

Running mkdir -p errors out on ubuntu-latest with:

error running container: error from crun creating container for [/bin/sh -c mkdir -p /mnt/rootfs]: cannot create state directory for `buildah-buildah504768355`

When buildah is previously used as root.

Here are the logs before the error occurs, if that helps:

Storage driver is not 'overlay', so not overriding storage configuration
Performing build from Containerfile
/usr/bin/buildah bud --platform linux/amd64 -f /home/runner/work/fedora-micro/fedora-micro/micro/Containerfile --build-arg VERSION_ID=37 --format docker --tls-verify=true -t fedora-micro:bfac1f5a9f5bb931958091c0e774ee6e6b933b0d-linuxamd64 /home/runner/work/fedora-micro/fedora-micro
[1/2] STEP 1/3: FROM quay.io/fedora/fedora:37 AS fedora-micro-build
...
[1/2] STEP 2/3: RUN mkdir -p /mnt/rootfs
error running container: error from crun creating container for [/bin/sh -c mkdir -p /mnt/rootfs]: cannot create state directory for `buildah-buildah562842614`
: exit status 1

Failing Action

Dockerfile

Steps to reproduce, workflow links, screenshots

  1. Build/modify some images with buildah outside redhat-actions/buildah-build@v2 as root
  2. Run a Dockerfile containing RUN mkdir in a GHA
  3. Observe error

The action runs fine when buildah is not invoked in previous steps.

np22-jpg commented 1 year ago

After switching from sudo to buildah unshare to run my script and only building with the buildah action, the issue has went away. It’s still weird how running a build as root would cause this, but it’s probably a non-issue.