My docker-compose lamp stack doesn't work after a software update : Error with 'ContainerConfig'
Asked Answered
R

3

5

EDIT : For problem resolution, see below.

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.

--- Resolution ---

The issue was due to the use of docker-compose instead of docker compose. It then showed a new error message:

$ docker compose up -d network
xxx_frontend was found but has incorrect label com.docker.compose.network set to "xxx_frontend"

After some search, I replaced the network part with the following

networks:
  frontend:
    name: ${DOCKER_IMAGE_PREFIX}_frontend
    driver: bridge
    labels:
      - "com.docker.compose.network=${DOCKER_IMAGE_PREFIX}_frontend"
  backend:
    name: ${DOCKER_IMAGE_PREFIX}_backend
    driver: bridge
    labels:
      - "com.docker.compose.network=${DOCKER_IMAGE_PREFIX}_backend"

And I also removed version, this is obsolete.

Then, I had some errors due to duplicates of the containers I wanted to run with docker compose up -d --build, so I purged it all.

docker container prune
docker image prune
docker volume prune
docker network prune

And now it works! (Second command removed 25 GB from disk, unbelievable!)

Ruthieruthless answered 24/3 at 10:32 Comment(3)
As usual, with most problems, start extracting a minimal reproducible example to isolate the issue.Cowardly
@UlrichEckhardt I edited the post, now the code is much smaller, but same error.Ruthieruthless
I don't believe that. In the error message, it refers to phpmyadmin and php, but according to your additional info, there is only apache. Also, no need to clutter your question with multiple version of the same question so people have to actively discard some of the info first. If necessary, older versions can be fetched from the history. BTW: You don't say how exactly you're starting this. Also, it might be relevant which versions you're using.Cowardly
L
8

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

Logogriph answered 26/3 at 13:17 Comment(2)
Thank you for your answer. You've put me on the right track! Issue resolution on the first post.Ruthieruthless
@Ruthieruthless what are different from my answer to that? I suggested to check docker compose first, then it seems you didn't see that.Catalonia
A
3

For me this helped:

docker-compose down
docker-compose up
Artwork answered 26/3 at 19:58 Comment(0)
C
1
  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.

Catalonia answered 24/3 at 13:7 Comment(2)
Thank you for your answer. Yes, I use docker-compose build and docker-compose up -d --remove-orphans to run it all. It was working before, it's very strange. I tried to add a volume as you did, but now I have another error : "ERROR: In file './docker-compose.yaml', volume must be a mapping, not an array" I'm not familiar with docker, maybe an error in the syntax? ThanksRuthieruthless
I deleted completely PMA, but the error still occurs with PHP...Ruthieruthless

© 2022 - 2024 — McMap. All rights reserved.