Kasper Dokter
Kasper Dokter

Reputation: 65

Docker compose fails on Raspberry Pi

Running $ docker compose up -d on the following docker-compose.yml

version: '3'

services:
  web:
    platform: linux/arm/v6
    build: ./web
    restart: always
    environment:
      DATABASE_URL: ${DATABASE_URL}
      SECRET_KEY: ${SECRET_KEY}
      TZ: Europe/Amsterdam
    ports:
      - ${PORT}:5000
    depends_on:
      - db
    volumes:
      - web-data:/data
  db:
    platform: linux/arm/v6
    image: arm32v6/postgres:15.1-alpine
    restart: always
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
    ports:
      - ${POSTGRES_PORT}:5432
    volumes:
      - postgres-data:/var/lib/postgresql/data

volumes:
  postgres-data:
  web-data:

should create two docker containers. However, it produces

[+] Building 6.5s (3/3) FINISHED
 => [internal] load build definition from Dockerfile               0.5s
 => => transferring dockerfile: 32B                                0.2s
 => [internal] load .dockerignore                                  0.2s
 => => transferring context: 2B                                    0.1s
 => ERROR resolve image config for docker.io/docker/dockerfile:1   2.4s
------
 > resolve image config for docker.io/docker/dockerfile:1:
------
failed to solve: rpc error: code = Unknown desc = failed to solve with frontend 
dockerfile.v0: failed to solve with frontend gateway.v0: no match for platform in manifest 
sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc: not found

I verified that both services (web and db) in my docker-compose file can be build using docker build, which excludes any platform issues from the services.

What does no match for platform in manifest mean? More importantly, how can I fix the error?

Upvotes: 1

Views: 555

Answers (1)

Kasper Dokter
Kasper Dokter

Reputation: 65

A temporary solution is to replace docker-compose.yml with explicit docker commands.

# Create the network and volumes                                                                                                                                                      
docker network create randpion-app
docker volume create postgres-data
docker volume create web-data

# Build the web service
docker build -t randpion/web web

# Load the environment variables from the .env file
export $(cat .env | xargs)

# Start the database service
docker run -d \
     --network randpion-app --network-alias db --name randpion-db \
     --platform "linux/arm/v6" \
     -v postgres-data:/var/lib/postgresql/data \
     -e POSTGRES_USER=${POSTGRES_USER} \
     -e POSTGRES_PASSWORD=${POSTGRES_PASSWORD} \
     -e POSTGRES_DB=${POSTGRES_DB} \
     -p ${POSTGRES_PORT}:5432 \
     arm32v6/postgres:15.1-alpine

# Start the web service
docker run -d \
     --network randpion-app --network-alias web --name randpion-web \
     --platform "linux/arm/v6" \
     -v web-data:/data \
     -e DATABASE_URL=${DATABASE_URL} \
     -e SECRET_KEY=${SECRET_KEY} \
     -e TZ=Europe/Amsterdam \
     -p ${PORT}:5000 \
     randpion/web

This runs fine for now, but the solution is not ideal. For example, the containers must restart after every reboot.

Upvotes: 1

Related Questions