Drupal fails after updating docker image to >=9.4.6 because of composer
vekunz opened this issue · 2 comments
Hi, I just tried to update the docker version of my Drupal site from 9.4.5 to the latest version 9.4.8. But it seems that Drupal fails to serve a page with any version since 9.4.6 of the Docker image. If I roll back to version 9.4.5, everything works fine again. If I remove the composer require
from the Dockerfile, everything works fine also.
If I try to open my site in the browser, it redirects me to /core/install.php
and just shows this error message:
Fatal error: Cannot redeclare format_size() (previously declared in /opt/drupal/web/core/includes/common.inc:137) in /opt/drupal/vendor/drupal/core/includes/common.inc on line 137
Since everything worked fine up to Docker image version 9.4.5, I assume that something has changed in the Docker image version 9.4.6 that causes the error.
This is my Dockerfile:
FROM drupal:9.4.8-php8.1
RUN composer require 'drupal/phpmailer_smtp:^2.0'
#RUN cd /usr/local/etc/php/ && \
# cp php.ini-production php.ini && \
# sed -i "s/post_max_size.*/post_max_size = 208M/g" php.ini && \
# sed -i "s/upload_max_filesize.*/upload_max_filesize = 200M/g" php.ini
This is my docker-compose.yml:
services:
drupal:
build: ./docker
ports:
- "127.0.0.1:8078:80"
restart: always
volumes:
- ./volumes/modules:/var/www/html/modules
- ./volumes/profiles:/var/www/html/profiles
- ./volumes/themes:/var/www/html/themes
- ./volumes/sites:/var/www/html/sites
I was experiencing this same issue, and I managed to fix it, but I'm not 100% sure how.
Instead of doing composer require [modules]
in the Dockerfile, I now do composer require [modules] --no-update
and then composer update
. This fixes the issue.
Would be very interested in why.
This works for me also, thank you.