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!)