Skip to content

bug: multi-arch parallel builds fails to obtain apt lock #5229

@aas47

Description

@aas47

Describe the bug

When using buildx, --platform=linux/amd64,linux/arm64 and {% block SETUP_BENTO_BASE_IMAGE %}, bentoml containerize fails with apt unable to obtain lock.

# short snippet
0.583 E: Could not get lock /var/lib/apt/lists/lock. It is held by process 0
0.584 E: Unable to lock directory /var/lib/apt/lists/

I'm new to bentoml so unsure where this config is coming from and how to update it. I haven't found a way to add something like sharing=shared or sharing=locked to this particular instruction. I found this is maybe where it needs to be added? I'm wondering how.

# full error
 > [linux/arm64 base-container  3/12] RUN --mount=type=cache,target=/var/lib/apt --mount=type=cache,target=/var/cache/apt set -eux &&     apt-get update -y &&     apt-get install -q -y --no-install-recommends --allow-remove-essential         ca-certificates gnupg2 bash build-essential:
0.142 + apt-get update -y
0.381 Reading package lists...
0.583 E: Could not get lock /var/lib/apt/lists/lock. It is held by process 0
0.584 E: Unable to lock directory /var/lib/apt/lists/
------
Dockerfile:22
--------------------
  21 |     RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
  22 | >>> RUN --mount=type=cache,target=/var/lib/apt --mount=type=cache,target=/var/cache/apt set -eux && \
  23 | >>>     apt-get update -y && \
  24 | >>>     apt-get install -q -y --no-install-recommends --allow-remove-essential \
  25 | >>>         ca-certificates gnupg2 bash build-essential
  26 |     # Build arguments -- passed in by bento as it does not allow env vars to be passed in
--------------------
ERROR: failed to solve: process "/bin/sh -c set -eux &&     apt-get update -y &&     apt-get install -q -y --no-install-recommends --allow-remove-essential         ca-certificates gnupg2 bash build-essential" did not complete successfully: exit code: 100

To reproduce

setup command:

docker buildx create --name container-builder --driver docker-container --bootstrap --use
docker buildx inspect --bootstrap
bentoml containerize testing:latest 
      --backend buildx
      --opt builder=container-builder
      --opt platform=linux/amd64,linux/arm64
      --opt pull
      --opt push
      -t "${MYIMAGETAG}"

and

# Dockerfile.template
{% extends bento_base_template %}
{% block SETUP_BENTO_BASE_IMAGE %}
{{ super() }}
{% endblock %}
{% block SETUP_BENTO_COMPONENTS %}
{{ super() }}
.
.
.
.
.
{% endblock %}

Expected behavior

expect the build to just pass.

Environment

docker:
  dockerfile_template: "Dockerfile.template"
  env:
    BUILD_ENV: local

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions