skip to Main Content

I updated my server today, docker containers and images too, but now it refuses to work properly. Maybe an update changed the way we need to write the docker-compose.yaml file? I didn’t change it for a while. It’s here:

version: "3.5"
services:
  php:
    build: 
      context: './php/'
      args:
       PHP_VERSION: ${PHP_VERSION}
    networks:
      - backend
    volumes:
      - ${PROJECT_ROOT}:/var/www/html/
      - /home/pi/docker-lamp-stack/baikal:/var/www/baikal/
    environment:
      MYSQL_HOST: "${DB_HOST}"
      MYSQL_DATABASE: "${DB_NAME}"
      MYSQL_USER: "${DB_USERNAME}"
      MYSQL_PASSWORD: "${DB_PASSWORD}"
      INSTANCE_NAME: "${INSTANCE_NAME}"
    container_name: ${DOCKER_IMAGE_PREFIX}php
    restart: unless-stopped
  apache:
    build:
      context: './apache/'
      args:
        APACHE_VERSION: ${APACHE_VERSION}
    depends_on:
      - php
    networks:
      - frontend
      - backend
    ports:
      - "443:443"
    volumes:
      - ${PROJECT_ROOT}:/var/www/html/
      - /etc/letsencrypt:/etc/letsencrypt/
      - /home/pi/docker-lamp-stack/baikal:/var/www/baikal/
    container_name: ${DOCKER_IMAGE_PREFIX}apache
    restart: always 
  mysql:
    image: mysql:${MYSQL_VERSION}
    command: 
      - mysqld
    restart: unless-stopped
    ports:
      - "${EXTERNAL_MYSQL_PORT}:3306"
    volumes:
            - ./mysql/data/:/var/lib/mysql
    networks:
      - backend
    environment:
      TZ: "${TZ}"
      MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD}"
      MYSQL_DATABASE: "${DB_NAME}"
      MYSQL_USER: "${DB_USERNAME}"
      MYSQL_PASSWORD: "${DB_PASSWORD}"
    container_name: ${DOCKER_IMAGE_PREFIX}mysql
  phpmyadmin:
    image: phpmyadmin:${PMA_VERSION}
    ports:
      - ${EXTERNAL_PMA_PORT}:80
    networks:
      - backend
      - frontend
    environment:
      - PMA_HOST=mysql
    restart: unless-stopped
    container_name: ${DOCKER_IMAGE_PREFIX}pma
networks:
  frontend:
    name: ${DOCKER_IMAGE_PREFIX}frontend
  backend:
    name: ${DOCKER_IMAGE_PREFIX}backend
volumes:
    data:

Some of the environment variables are

PHP_VERSION=8.2
MYSQL_VERSION=oracle
APACHE_VERSION=2
PMA_VERSION=latest

Errors are

ERROR: for php 'ContainerConfig'

ERROR: for phpmyadmin  'ContainerConfig'
Traceback (most recent call last):
  File "/usr/local/bin/docker-compose", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/dist-packages/compose/cli/main.py", line 81, in main
    command_func()
  File "/usr/local/lib/python3.9/dist-packages/compose/cli/main.py", line 203, in perform_command
    handler(command, command_options)
  File "/usr/local/lib/python3.9/dist-packages/compose/metrics/decorator.py", line 18, in wrapper
    result = fn(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/compose/cli/main.py", line 1186, in up
    to_attach = up(False)
  File "/usr/local/lib/python3.9/dist-packages/compose/cli/main.py", line 1166, in up
    return self.project.up(
  File "/usr/local/lib/python3.9/dist-packages/compose/project.py", line 697, in up
    results, errors = parallel.parallel_execute(
  File "/usr/local/lib/python3.9/dist-packages/compose/parallel.py", line 108, in parallel_execute
    raise error_to_reraise
  File "/usr/local/lib/python3.9/dist-packages/compose/parallel.py", line 206, in producer
    result = func(obj)
  File "/usr/local/lib/python3.9/dist-packages/compose/project.py", line 679, in do
    return service.execute_convergence_plan(
  File "/usr/local/lib/python3.9/dist-packages/compose/service.py", line 579, in execute_convergence_plan
    return self._execute_convergence_recreate(
  File "/usr/local/lib/python3.9/dist-packages/compose/service.py", line 499, in _execute_convergence_recreate
    containers, errors = parallel_execute(
  File "/usr/local/lib/python3.9/dist-packages/compose/parallel.py", line 108, in parallel_execute
    raise error_to_reraise
  File "/usr/local/lib/python3.9/dist-packages/compose/parallel.py", line 206, in producer
    result = func(obj)
  File "/usr/local/lib/python3.9/dist-packages/compose/service.py", line 494, in recreate
    return self.recreate_container(
  File "/usr/local/lib/python3.9/dist-packages/compose/service.py", line 612, in recreate_container
    new_container = self.create_container(
  File "/usr/local/lib/python3.9/dist-packages/compose/service.py", line 330, in create_container
    container_options = self._get_container_create_options(
  File "/usr/local/lib/python3.9/dist-packages/compose/service.py", line 921, in _get_container_create_options
    container_options, override_options = self._build_container_volume_options(
  File "/usr/local/lib/python3.9/dist-packages/compose/service.py", line 960, in _build_container_volume_options
    binds, affinity = merge_volume_bindings(
  File "/usr/local/lib/python3.9/dist-packages/compose/service.py", line 1548, in merge_volume_bindings
    old_volumes, old_mounts = get_container_data_volumes(
  File "/usr/local/lib/python3.9/dist-packages/compose/service.py", line 1579, in get_container_data_volumes
    container.image_config['ContainerConfig'].get('Volumes') or {}
KeyError: 'ContainerConfig'

Only apache and mysql start.

  • My docker version is 26.0.0
  • My docker-compose version is 1.29.2
  • Changing PHP and/or PMA version don’t change the problem.

Someone has an idea of what’s happening ?
Thanks

EDIT : Changes of the config, much smaller, but still the error:

The docker-compose.yaml is now:

version: "3.5"
services:
  apache:
    build:
      context: './apache/'
      args:
        APACHE_VERSION: 2
    networks:
      - frontend
      - backend
    ports:
      - "4443:443"
    volumes:
      - ./:/var/www/html/
      - ./letsencrypt:/etc/letsencrypt/
      - ./baikal:/var/www/baikal/
    container_name: testapache
    restart: always
networks:
  frontend:
    name: testfrontend
  backend:
    name: testbackend
volumes:
    data:

In ./apache, Dockerfile is (unchanged):

ARG APACHE_VERSION=""
FROM httpd:${APACHE_VERSION:+${APACHE_VERSION}-}alpine

RUN apk update; apk upgrade; apk add brotli

COPY conf /usr/local/apache2/conf/
COPY mod_xsendfile.so /usr/local/apache2/modules/mod_xsendfile.so

Building php alone works, as well as PMA alone.

2

Answers


    1. Docker compose command.

    Have you run your compose file with docker-compose up -d?
    If so, try to run with
    docker compose up -d
    This is because docker-compose is v1 syntax and deprecated as shown in the following docker compose page.

    1. Volume is essential as required.

    Volume could be required depends on the image.
    Expected to have persistent volume for its data in phpmyadmin if needed.

    So your docker-compose.yaml file would have volume defined:

    version: "3.5"
    services:
      php:
        build: 
          context: './php/'
          args:
           PHP_VERSION: ${PHP_VERSION}
        networks:
          - backend
        volumes:
          - ${PROJECT_ROOT}:/var/www/html/
          - /home/pi/docker-lamp-stack/baikal:/var/www/baikal/
        environment:
          MYSQL_HOST: "${DB_HOST}"
          MYSQL_DATABASE: "${DB_NAME}"
          MYSQL_USER: "${DB_USERNAME}"
          MYSQL_PASSWORD: "${DB_PASSWORD}"
          INSTANCE_NAME: "${INSTANCE_NAME}"
        container_name: ${DOCKER_IMAGE_PREFIX}php
        restart: unless-stopped
      ...
      ...
      phpmyadmin:
        image: phpmyadmin:${PMA_VERSION}
        ports:
          - ${EXTERNAL_PMA_PORT}:80
        networks:
          - backend
          - frontend
        environment:
          - PMA_HOST=mysql
        restart: unless-stopped
        container_name: ${DOCKER_IMAGE_PREFIX}pma
    networks:
      frontend:
        name: ${DOCKER_IMAGE_PREFIX}frontend
      backend:
        name: ${DOCKER_IMAGE_PREFIX}backend
    volumes:
        - data:
        - phpmyadmin_data:/var/lib/phpmyadmin
    

    Otherwise, you can leave it empty as

    volumes:
        - data:
        - phpmyadmin_data:
    

    Overall, I expect the first option with compose command should work.

    Login or Signup to reply.
  1. Try to use docker compose command, and not docker-compose that is no longer recommended (see https://docs.docker.com/compose/migrate/)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search