Skip to content

Support rootless bootc-image-builder#445

Merged
achilleas-k merged 2 commits intoosbuild:mainfrom
alexlarsson:rootless
Jan 29, 2026
Merged

Support rootless bootc-image-builder#445
achilleas-k merged 2 commits intoosbuild:mainfrom
alexlarsson:rootless

Conversation

@alexlarsson
Copy link
Contributor

This MR + a bootc-image-builder with this change:

diff --git a/bib/cmd/bootc-image-builder/main.go b/bib/cmd/bootc-image-builder/main.go
index be4b064..c6c3503 100644
--- a/bib/cmd/bootc-image-builder/main.go
+++ b/bib/cmd/bootc-image-builder/main.go
@@ -268,7 +268,7 @@ func cmdBuild(cmd *cobra.Command, args []string) error {
        runInVM, _ := cmd.Flags().GetBool("in-vm")
 
        logrus.Debug("Validating environment")
-       if err := setup.Validate(targetArch); err != nil {
+       if err := setup.Validate(targetArch, runInVM); err != nil {
                return fmt.Errorf("cannot validate the setup: %w", err)
        }
        logrus.Debug("Ensuring environment setup")

And a localhost/bootc-image-builder container built with osbuild 171 allows us to run a rootless podman container with b-c-i-b:

$ touch /tmp/foo
$ podman run --rm --security-opt label=type:unconfined_t -ti --privileged --network=none -v $PWD/output:/output -v ~/.local/share/containers/storage:/var/lib/containers/storage -v /tmp/foo:/var/lib/containers/storage/db.sql localhost/bootc-image-builder --progress verbose --rootfs ext4 --in-vm --type raw quay.io/fedora/fedora-bootc:43

Its unfortunate that we have to mount over the db.sql, but if we don't, then we get this error:

2026/01/28 16:09:01 error: cannot build manifest: failed to inspect the image: exit status 125, stderr:
Error: database static dir "/home/alex/.local/share/containers/storage/libpod" does not match our static dir "/var/lib/containers/storage/libpod": database configuration mismatch

I don't know how to avoid this. I tried exposing the user container store using additional image stores, but I ran into tons of issues with bc-i-b and osbuild hardcoding /var/lib/containers/storage, which means the additional image store is ignored. Maybe we can fix those, or maybe we can change podman to avoid this error. Or maybe we can do the workaround in the bootc-i-b setup code.

@alexlarsson alexlarsson requested a review from a team as a code owner January 28, 2026 16:12
@alexlarsson alexlarsson requested review from croissanne, supakeen and thozza and removed request for a team January 28, 2026 16:12
@alexlarsson
Copy link
Contributor Author

Hmm, seems the /dev/loop workaround didn't work that way. I'll try hanging it off in-vm instead.

// Validate checks that the environment is supported (e.g. caller set up the
// container correctly)
func Validate(targetArch string) error {
func Validate(targetArch string, inVm bool) error {

Choose a reason for hiding this comment

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

I noticed a missing unit-test in setup_test.go. Since the Validate method declaration has changed. I think the tests should be updated to cover this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no current test for this, but I can look at adding one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It may be a bit tricky though, as it relies on checking global properties of the current sandbox.

Copy link

@maboras-rh maboras-rh Jan 28, 2026

Choose a reason for hiding this comment

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

Clear, thanks for clarification.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm looking at this, and it doesn't really seem useful/possible to unit test this in a reasonable way. Some individual functions it uses are tested , like validateCanRunTargetArch is tested by TestValidateCanRunTargetArch*, but the remaining parts need to have a complete container image built to test.

If we're running in a virtual machine, there is no need to mount /dev
in the container (it will be mounted in the vm). This is important
because in a rootless container we're not allowed to mount devtmpfs.
If in vm, we don't need --privileged. Also, we can also support
rootless containers.
Copy link
Member

@supakeen supakeen left a comment

Choose a reason for hiding this comment

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

Thank you.

@supakeen supakeen requested a review from achilleas-k January 29, 2026 11:44
Copy link
Member

@achilleas-k achilleas-k left a comment

Choose a reason for hiding this comment

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

neat!

@achilleas-k achilleas-k added this pull request to the merge queue Jan 29, 2026
Merged via the queue into osbuild:main with commit 81814bf Jan 29, 2026
45 checks passed
alexlarsson added a commit to osbuild/bootc-image-builder that referenced this pull request Jan 29, 2026
This updates to the latest image-builder-cli, adding support for
rootless container use
(osbuild/image-builder-cli#445).

It also updates the use of related APIs to pass runInVm options where
needed.

With this, I was able to run a rootless bc-i-b conversion. There is
one problem, which is that if you mount ~/.local/share/containers/storage on the host
to /var/lib/containers/storage in the contained, podman will complain with:

Error: database static dir "~/.local/share/containers/storage/libpod"
does not match our static dir "/var/lib/containers/storage/libpod":
database configuration mismatch

Additionally, if you pass the host "/var/lib/containers/storage" into
the rootless container you will get read permission errors.

There are two workarounds for this. Either you can use e.g. skopeo to
copy the bootc container to a separate (non-root) container storage
directory and mount that, or you can cover the "db.sql" file in the
storage directory to make podman not print the error.

Neither of these are super clean, and we should try to figure out a
better solution, but for now I was at least able to run a complete image build using:

```
$ touch /tmp/foo
$ podman run --rm --security-opt label=type:unconfined_t -ti --privileged \
  --network=none -v $PWD/output:/output \
  -v ~/.local/share/containers/storage:/var/lib/containers/storage \
  -v /tmp/foo:/var/lib/containers/storage/db.sql \
  localhost/bootc-image-builder  --in-vm \
  --rootfs ext4 --type raw \
  quay.io/fedora/fedora-bootc:43
```
alexlarsson added a commit to osbuild/bootc-image-builder that referenced this pull request Jan 29, 2026
This updates to the latest image-builder-cli, adding support for
rootless container use
(osbuild/image-builder-cli#445).

It also updates the use of related APIs to pass runInVm options where
needed.

With this, I was able to run a rootless bc-i-b conversion. There is
one problem, which is that if you mount ~/.local/share/containers/storage on the host
to /var/lib/containers/storage in the contained, podman will complain with:

Error: database static dir "~/.local/share/containers/storage/libpod"
does not match our static dir "/var/lib/containers/storage/libpod":
database configuration mismatch

Additionally, if you pass the host "/var/lib/containers/storage" into
the rootless container you will get read permission errors.

There are two workarounds for this. Either you can use e.g. skopeo to
copy the bootc container to a separate (non-root) container storage
directory and mount that, or you can cover the "db.sql" file in the
storage directory to make podman not print the error.

Neither of these are super clean, and we should try to figure out a
better solution, but for now I was at least able to run a complete image build using:

```
$ touch /tmp/foo
$ podman run --rm --security-opt label=type:unconfined_t -ti --privileged \
  --network=none -v $PWD/output:/output \
  -v ~/.local/share/containers/storage:/var/lib/containers/storage \
  -v /tmp/foo:/var/lib/containers/storage/db.sql \
  localhost/bootc-image-builder  --in-vm \
  --rootfs ext4 --type raw \
  quay.io/fedora/fedora-bootc:43
```
alexlarsson added a commit to osbuild/bootc-image-builder that referenced this pull request Feb 2, 2026
This updates to the latest image-builder-cli, adding support for
rootless container use
(osbuild/image-builder-cli#445).

It also updates the use of related APIs to pass runInVm options where
needed.

With this, I was able to run a rootless bc-i-b conversion.

There is one problem, which is that if you mount
`~/.local/share/containers/storage` on the host to
`/var/lib/containers/storage` in the container, podman will complain
with:

```
Error: database static dir "~/.local/share/containers/storage/libpod"
does not match our static dir "/var/lib/containers/storage/libpod":
database configuration mismatch
```

Additionally, if you pass the host `/var/lib/containers/storage` into
the rootless container you will get read permission errors.

There are two workarounds for this. Either you can use e.g. skopeo to
copy the bootc container to a separate (non-root) container storage
directory and mount that, or you can cover the `db.sql` file in the
storage directory to make podman not print the error.

Neither of these are super clean, and we should try to figure out a
better solution, but for now I was at least able to run a complete
image build using the "cover db" apprach like this:

```
$ touch /tmp/foo
$ podman run --rm --security-opt label=type:unconfined_t -ti --privileged \
  --network=none -v $PWD/output:/output \
  -v ~/.local/share/containers/storage:/var/lib/containers/storage \
  -v /tmp/foo:/var/lib/containers/storage/db.sql \
  localhost/bootc-image-builder  --in-vm \
  --rootfs ext4 --type raw \
  quay.io/fedora/fedora-bootc:43
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants