moby / moby/buildkit

[BUG] Stuck on docker compose build when using buildkit

Open
#3,975 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status/needs-investigation
Dominant language
Go
Stars
10.3k
Forks
1.5k
Avg merge
1d 21h
Merged PRs (30d)
50

Description

I have mentioned the problem here

I have 5 different services in a docker compose environment.
One of the services Dockerfile is like this:

FROM python:3.10.4-slim AS Development

# Add a non-root user
RUN useradd -ms /bin/bash python

# Install dependencies for compiling psycopg2
RUN apt update -y && apt install -y libpq-dev
RUN apt install -y build-essential gcc

This works fine with the following yaml file:

version: "3.9"
services:
  api:
    build:
      context: ../api
      target: Development
    restart: always

When I add another stage onto that Dockerfile

FROM python:3.10.4-slim AS Development

# Add a non-root user
RUN useradd -ms /bin/bash python

# Install dependencies for compiling psycopg2
RUN apt update -y && apt install -y libpq-dev
RUN apt install -y build-essential gcc

#
#
#

FROM Development AS Staging
USER root
RUN apt update -y

and change the yaml file

version: "3.9"
services:
  api:
    build:
      context: ../api
      target: Staging
    restart: always

suddenly the docker compose build will stop working and says messages like [CANCELED] load build definition from dockerfile and get stuck on this message forever.

after reading the following issue (https://github.com/docker/compose/issues/10143) and disbling the buildkit

export DOCKER_BUILDKIT=0 ;
docker compose build

it seems to be working again.

docker version:

Client:
 Version:           20.10.21
 API version:       1.41
 Go version:        go1.18.1
 Git commit:        20.10.21-0ubuntu1~22.04.3
 Built:             Thu Apr 27 05:57:17 2023
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.21
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.1
  Git commit:       20.10.21-0ubuntu1~22.04.3
  Built:            Thu Apr 27 05:37:25 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.5.9-0ubuntu3.1
  GitCommit:        
 runc:
  Version:          1.1.4-0ubuntu1~22.04.3
  GitCommit:        
 docker-init:
  Version:          0.19.0
  GitCommit:        

My system is Ubuntu 22.04

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the hang with the two-stage Dockerfile targeting Staging through the shown Docker Compose service, using Docker BuildKit enabled and disabled for comparison. Start by tracing the canceled “load build definition from dockerfile” step and use the reported Docker 20.10.21, Ubuntu 22.04 environment; done means the staged build completes with BuildKit enabled or the failure is clearly diagnosed and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, docker-compose, dockerfile
Domain
build-system, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.