2

I am building arm64 image on my x86_64 amd machine using docker buildx everything is working fine except whenever I try to build arm image it start building it from scratch.

Steps to reproduce

  1. Create a docker builder
    export DOCKER_CLI_EXPERIMENTAL=enabled
    docker buildx create --name buildkit
    docker buildx use buildkit
    docker buildx inspect --bootstrap
    
  2. Build docker image using command
    docker buildx build . --platform linux/arm64 -t test-image:p-arm64 -f ./arm64.Dockerfile
    

When I build it multiple time all the steps are executing which takes around 20-30 min for every build. I want to minimize this time by caching.

This is what my dockerfile looks like

FROM python:3.7-slim

USER root

RUN apt-get update && \
    apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common \
    gnupg \
    g++ \
    && rm -rf /var/lib/apt/lists/*

RUN curl -fsSL https://download.docker.com/linux/debian/gpg |  gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg && \
    echo "deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
    $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null

RUN apt-get update && \
    apt-get install -y docker-ce-cli \
    && rm -rf /var/lib/apt/lists/*

RUN python3 -m pip install --no-cache-dir \
    ruamel.yaml==0.16.12 \
    pyyaml==5.4.1 \
    requests==2.27.1

RUN apt-get remove -y g++ && apt-get purge g++

ENTRYPOINT ["/bin/bash"]

Any suggestion is appretiated.

Pranjal Doshi
  • 862
  • 11
  • 29

0 Answers0