Docker BuildKit on Fedora Silverblue

Silverblue is a great project and I would like to try it on a daily basis, but I can’t because Docker BuildKit does not work.

I have a small sample-Dockerfile with only the following content:

# syntax = docker/dockerfile
FROM node:12-alpine

When I try to build with this command:

sudo DOCKER_BUILDKIT=1 docker build .

I get this output:

[+] Building 1.2s (4/4) FINISHED                                                                        
 => [internal] load build definition from Dockerfile                                               0.1s
 => => transferring dockerfile: 152B                                                               0.0s
 => [internal] load .dockerignore                                                                  0.1s
 => => transferring context: 2B                                                                    0.0s
 => resolve image config for                                    1.0s
 => CACHED docker-image://  0.0s
failed to solve with frontend dockerfile.v0: failed to solve with frontend gateway.v0: exit code: 1

I installed docker as layered application on a brand new Fedora 34 Silverblue instance as virtual machine.

Is there something what I can do?

You can use podman to build that container and run it. In the directory of the container file enter 'podman build -f ’ then select the image and podman will build it for you without being root. After it is built, run it with 'podman run -it '. I just did it now, it works. You will likely need to look at the options for sharing a directory in your home, or networking possibly.

Good luck!

I’m not familiar with how BuildKit works but would suggest trying that in a classic Fedora virtual machine to make sure this is not specific to Silverblue and probably open a bug report for the docker or moby-engine package.

Thanks for you fast response. I can confirm, that podman works for this easy example. But for my project, I need to use a “docker sdk”, which internally calls docker directly. And it uses docker compose as well.

I tried it with an symlink, but it doesn’t work.

Yes, it is working on Fedora Workstation 34 and on Ubuntu 21.04. Is there a way to find out why this is not working on Silverblue?

I’m not sure if it would work for your needs, but I am aware of podman-docker (which basically adds a symlink for you) and podman-compose (which is similar to docker-compose).

Additionally, you can use docker-compose itself with podman, as shown in this article:

The quick summary of the article, to get docker-compose working with podman, adapted to Silverblue:

rpm-ostree install --apply-live podman-docker docker-compose
sudo systemctl enable --now podman.socket

(I think this can be applied live without rebooting, but rpm-ostree should tell you if you do need a reboot.)

And then you should be able to run docker-compose with podman as a backend, as long as you don’t need swarm functionality.

Again, I don’t know if it works with BuildKit or not, but it’s probably worth a try.

Also, there are a few buildkit-related packages in Fedora (which I guess you know about already?), but I don’t know if they work with podman with the compatibility stuff installed.

$ dnf search buildkit
==================================================================== Name Matched: buildkit =====================================================================
golang-github-moby-buildkit.x86_64 : Concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit
golang-github-moby-buildkit-client-connhelper-dockercontainer-devel.noarch : Concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit
golang-github-moby-buildkit-devel.noarch : Concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit

If it works on Workstation, it probably means that BuildKit is doing something fishy. We would need better logs to get the actual error. I don’t know how to do that unfortunately.

See also: Using Podman with BuildKit, the better Docker image builder