Docker Buildkit on Ubuntu 20.04 not working

So I’m trying to use Docker buildkit features such as parallelization on my local machine and it does not work, what am I missing here? I installed docker using Docker documentation

What am I trying to do? I’m trying to build this Dockerfile:

FROM alpine AS build1
RUN touch /opt/binary1
RUN sleep 10

FROM alpine AS build2
RUN touch /opt/binary2
RUN sleep 10

FROM alpine as final
COPY --from=build1 /opt/binary1 /opt/
COPY --from=build2 /opt/binary2 /opt/

And build it using this command:

time DOCKER_BUILDKIT=1 sudo docker build .

As I understood this should run in parallel, but it doesn’t.

I’ve stumbled upon this by watching this video (from minute 5):

My OS version is: 20.04.5 LTS (Focal Fossa)

docker version

Client: Docker Engine - Community
 Version:           20.10.21
 API version:       1.41
 Go version:        go1.18.7
 Git commit:        baeda1f
 Built:             Tue Oct 25 18:02:21 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
  Version:          20.10.21
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.7
  Git commit:       3056208
  Built:            Tue Oct 25 18:00:04 2022
  OS/Arch:          linux/amd64
  Experimental:     false
  Version:          1.6.10
  GitCommit:        770bd0108c32f3fb5c73ae1264f7e503fe7b2661
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
  Version:          0.19.0
  GitCommit:        de40ad0

I’ve tried this on multiple Ubuntu versions (using cloud provider) and the result is the same, what am I missing?


Buildkit enabled - Dockerfile not building in parallel

I am afraid this is rather a linux usage problem, than a docker problem.

While this doesn’t work:

This one will:

time DOCKER_BUILDKIT=1 sudo -E docker build .

The -E argument passes the shell variables to command executed by sudo.


I forget to mention that you made an excellent post! It allows to fully understand what you tried, what the outcome was, what you expected and how everything can be reproduced.

Thank you for that!

I should also have mentioned that the screenshot of the build log shows a classic build log, and not a buildkit build log => buildkit was not used at all. The sudo command simply swallowed the environment variable to enable buildkit.

1 Like

Thank You @meyay very much, this solved my problem entirely. I’ve known that there is one thing that I overlooked but couldn’t find what it was.
And thank You for this praisal :heart: