I am trying to build an image that works fine on mac on a ubuntu 20 virtual machine. on my host computer I run docker-compose --debug -f local.yml build and it works fine.
docker-compose --debug -f local.yml build
when I type the same command into ubuntu i get:
DEBU[0000] using default config store "/Users/lancemeister/.docker/buildx"
[+] Building 3.9s (20/42)
=> [meister_affiliate_shop_local_docs internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.85kB 0.0s
=> [meister_affiliate_shop_local_django internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.90kB 0.0s
=> [meister_affiliate_shop_production_postgres internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 32B 0.0s
=> [meister_affiliate_shop_local_docs internal] load .dockerignore 0.0s
=> => transferring context: 34B 0.0s
=> [meister_affiliate_shop_production_postgres internal] load .dockerignore 0.0s
=> => transferring context: 34B 0.0s
=> [meister_affiliate_shop_local_django internal] load .dockerignore 0.0s
=> => transferring context: 34B 0.0s
=> [meister_affiliate_shop_local_docs internal] load metadata for docker.io/library/python:3.10-slim-bu 2.9s
=> [meister_affiliate_shop_production_postgres internal] load metadata for docker.io/library/postgres:1 3.0s
=> [auth] library/python:pull token for registry-1.docker.io 0.0s
=> [auth] library/postgres:pull token for registry-1.docker.io 0.0s
=> [meister_affiliate_shop_local_docs internal] load build context 0.0s
=> => transferring context: 935B 0.0s
=> CACHED [meister_affiliate_shop_local_docs python 1/1] FROM docker.io/library/python:3.10-slim-bullse 0.0s
=> [meister_affiliate_shop_local_django internal] load build context 0.5s
=> => transferring context: 19.58MB 0.5s
=> CACHED [meister_affiliate_shop_local_django python-run-stage 1/11] WORKDIR /app 0.0s
=> CANCELED [meister_affiliate_shop_local_django python-run-stage 2/11] RUN apt-get update && apt-get 0.8s
=> ERROR [meister_affiliate_shop_local_django python-build-stage 1/3] RUN apt-get update && apt-get ins 0.7s
=> ERROR [meister_affiliate_shop_local_docs python-build-stage 1/3] RUN apt-get update && apt-get insta 0.7s
=> ERROR [meister_affiliate_shop_local_docs python-run-stage 1/7] RUN apt-get update && apt-get install 0.7s
=> [meister_affiliate_shop_production_postgres internal] load build context 0.4s
=> => transferring context: 1.18kB 0.3s
=> CANCELED [meister_affiliate_shop_production_postgres 1/4] FROM docker.io/library/postgres:14@sha256: 0.6s
=> => resolve docker.io/library/postgres:14@sha256:cfd6203fc331bdf87ddf8c0ae91d9a6a6eacd5f2037c8178b644 0.0s
=> => sha256:f3ac85625e767ee0ec42b5a2ef93880251cd973b86f77124c4ed39bccd2f8bf9 0B / 30.06MB 0.7s
=> => sha256:378ffab63dc8bd21f2cd698be82bb12d9c0ba6aa5fbbc6c108b13721f37b2af8 0B / 4.42MB 0.7s
=> => sha256:036dbcdfa9cc43389f78510995735fd9a65dd14039d1b3c4303cfd33401e607d 0B / 1.80kB 0.7s
=> => sha256:cfd6203fc331bdf87ddf8c0ae91d9a6a6eacd5f2037c8178b644f1bbc369fafe 1.86kB / 1.86kB 0.0s
=> => sha256:0c29696257f7d05ad715f8415a40de4eeab35a8f74df2e418b06f30fd2808a4b 3.04kB / 3.04kB 0.0s
=> => sha256:af7af9ca355e4c01a4b9b0254b6bf811772fcc099d4d7ad445fb56d8f737ba9d 10.53kB / 10.53kB 0.0s
------
> [meister_affiliate_shop_local_django python-build-stage 1/3] RUN apt-get update && apt-get install --no-install-recommends -y build-essential libpq-dev:
#0 0.644 exec /bin/sh: exec format error
------
------
> [meister_affiliate_shop_local_docs python-build-stage 1/3] RUN apt-get update && apt-get install --no-install-recommends -y build-essential libpq-dev && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && rm -rf /var/lib/apt/lists/*:
#0 0.666 exec /bin/sh: exec format error
------
------
> [meister_affiliate_shop_local_docs python-run-stage 1/7] RUN apt-get update && apt-get install --no-install-recommends -y make libpq-dev gettext && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && rm -rf /var/lib/apt/lists/*:
#0 0.696 exec /bin/sh: exec format error
------
DEBU[0000] serving grpc connection
DEBU[0000] stopping session span="load buildkit capabilities"
DEBU[0000] serving grpc connection
DEBU[0000] serving grpc connection
DEBU[0000] serving grpc connection
DEBU[0004] stopping session span=meister_affiliate_shop_local_docs
DEBU[0004] stopping session span=meister_affiliate_shop_local_django
DEBU[0004] stopping session span=meister_affiliate_shop_production_postgres
failed to solve: executor failed running [/bin/sh -c apt-get update && apt-get install --no-install-recommends -y make libpq-dev gettext && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && rm -rf /var/lib/apt/lists/*]: exit code: 1
local.yml
version: '3'
volumes:
meister_affiliate_shop_local_postgres_data: {}
meister_affiliate_shop_local_postgres_data_backups: {}
services:
django:
build:
context: .
dockerfile: ./compose/local/django/Dockerfile
image: meister_affiliate_shop_local_django
container_name: meister_affiliate_shop_local_django
platform: linux/arm64
depends_on:
- postgres
volumes:
- .:/app:z
env_file:
- ./.envs/.local/.django
- ./.envs/.local/.postgres
ports:
- "8000:8000"
command: /start
postgres:
build:
context: .
dockerfile: ./compose/production/postgres/Dockerfile
image: meister_affiliate_shop_production_postgres
container_name: meister_affiliate_shop_local_postgres
volumes:
- meister_affiliate_shop_local_postgres_data:/var/lib/postgresql/data:Z
- meister_affiliate_shop_local_postgres_data_backups:/backups:z
env_file:
- ./.envs/.local/.postgres
docs:
image: meister_affiliate_shop_local_docs
container_name: meister_affiliate_shop_local_docs
platform: linux/x86_64
build:
context: .
dockerfile: ./compose/local/docs/Dockerfile
env_file:
- ./.envs/.local/.django
volumes:
- ./docs:/docs:z
- ./config:/app/config:z
- ./meister_affiliate_shop:/app/meister_affiliate_shop:z
ports:
- "9000:9000"
command: /start-docs
.compose/local/django/Dockerfile
ARG PYTHON_VERSION=3.10-slim-bullseye
# define an alias for the specfic python version used in this file.
FROM python:${PYTHON_VERSION} as python
# Python build stage
FROM python as python-build-stage
ARG BUILD_ENVIRONMENT=local
# Install apt packages
RUN apt-get update && apt-get install --no-install-recommends -y \
# dependencies for building Python packages
build-essential \
# psycopg2 dependencies
libpq-dev
# Requirements are installed here to ensure they will be cached.
COPY ./requirements .
# Create Python Dependency and Sub-Dependency Wheels.
RUN pip wheel --wheel-dir /usr/src/app/wheels \
-r ${BUILD_ENVIRONMENT}.txt
# Python 'run' stage
FROM python as python-run-stage
ARG BUILD_ENVIRONMENT=local
ARG APP_HOME=/app
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV BUILD_ENV ${BUILD_ENVIRONMENT}
WORKDIR ${APP_HOME}
# Install required system dependencies
RUN apt-get update && apt-get install --no-install-recommends -y \
# psycopg2 dependencies
libpq-dev \
# Translations dependencies
gettext \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
# All absolute dir copies ignore workdir instruction. All relative dir copies are wrt to the workdir instruction
# copy python dependency wheels from python-build-stage
COPY --from=python-build-stage /usr/src/app/wheels /wheels/
# use wheels to install python dependencies
RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \
&& rm -rf /wheels/
COPY ./compose/production/django/entrypoint /entrypoint
RUN sed -i 's/\r$//g' /entrypoint
RUN chmod +x /entrypoint
COPY ./compose/local/django/start /start
RUN sed -i 's/\r$//g' /start
RUN chmod +x /start
# copy application code to WORKDIR
COPY . ${APP_HOME}
ENTRYPOINT ["/entrypoint"]
.compose/local/docs/Dockerfile
ARG PYTHON_VERSION=3.10-slim-bullseye
# define an alias for the specfic python version used in this file.
FROM python:${PYTHON_VERSION} as python
# Python build stage
FROM python as python-build-stage
ENV PYTHONDONTWRITEBYTECODE 1
RUN apt-get update && apt-get install --no-install-recommends -y \
# dependencies for building Python packages
build-essential \
# psycopg2 dependencies
libpq-dev \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
# Requirements are installed here to ensure they will be cached.
COPY ./requirements /requirements
# create python dependency wheels
RUN pip wheel --no-cache-dir --wheel-dir /usr/src/app/wheels \
-r /requirements/local.txt -r /requirements/production.txt \
&& rm -rf /requirements
# Python 'run' stage
FROM python as python-run-stage
ARG BUILD_ENVIRONMENT
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
RUN apt-get update && apt-get install --no-install-recommends -y \
# To run the Makefile
make \
# psycopg2 dependencies
libpq-dev \
# Translations dependencies
gettext \
# Uncomment below lines to enable Sphinx output to latex and pdf
# texlive-latex-recommended \
# texlive-fonts-recommended \
# texlive-latex-extra \
# latexmk \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
# copy python dependency wheels from python-build-stage
COPY --from=python-build-stage /usr/src/app/wheels /wheels
# use wheels to install python dependencies
RUN pip install --no-cache /wheels/* \
&& rm -rf /wheels
COPY ./compose/local/docs/start /start-docs
RUN sed -i 's/\r$//g' /start-docs
RUN chmod +x /start-docs
WORKDIR /docs
I would really apprieciate any help that i can get with problem. thanks.
I figured out the problem, and it was that I was using an arm distribution I needed to choose containers that were also using the arm64 platform, and then it worked