moodlehq / moodle-docker

A docker environment for moodle developers
GNU General Public License v3.0
373 stars 244 forks source link

Webserver exits on M1 #248

Closed mackensen closed 1 year ago

mackensen commented 1 year ago

The webserver container exits immediately on an M1 laptop running Ventura 13.0.1:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.20.0.6. Set the 'ServerName' directive globally to suppress this message [Wed Jan 25 21:36:38.675378 2023] [core:emerg] [pid 1] (95)Operation not supported: AH00023: Couldn't create the proxy mutex [Wed Jan 25 21:36:38.679179 2023] [proxy:crit] [pid 1] (95)Operation not supported: AH02478: failed to create proxy mutex AH00016: Configuration Failed

May be related to https://stackoverflow.com/questions/73294020/docker-couldnt-create-the-mpm-accept-mutex

scara commented 1 year ago

Hi @mackensen, unfortunately I do not have an M1 and in my Raspberry Pi 4 Model B (aarch64) the HQ image works fine e.g. 8.0:

Status: Downloaded newer image for moodlehq/moodle-php-apache:8.0
...
[Sun Jan 29 10:47:03.371432 2023] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.54 (Debian) PHP/8.0.27 configured -- resuming normal operations
[Sun Jan 29 10:47:03.371588 2023] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

Would you mind to give the quick&dirty patch below a test run in your M1?

Clone the repo

$ git clone https://github.com/moodlehq/moodle-php-apache

Patch the Dockerfile

$ git diff
diff --git a/Dockerfile b/Dockerfile
index ad3d20a..e3e2191 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -34,6 +34,10 @@ RUN /tmp/setup/php-extensions.sh
 RUN /tmp/setup/oci8-extension.sh
 ENV LD_LIBRARY_PATH /usr/local/instantclient

+# Setup the required configurations.
+# TODO Use a setup script and let the following sed run only when "${TARGETPLATFORM}" == "linux/arm64".
+RUN sed -i '/^#Mutex.*/a Mutex posixsem' /etc/apache2/apache2.conf
+
 RUN mkdir /var/www/moodledata && chown www-data /var/www/moodledata && \
     mkdir /var/www/phpunitdata && chown www-data /var/www/phpunitdata && \
     mkdir /var/www/behatdata && chown www-data /var/www/behatdata && \

Build the arm64 target platform and load it in your Docker Engine

$ docker buildx create --use
$ docker buildx build --platform=linux/arm64 --load -t moodlehq/moodle-php-apache:8.2-test-posix .

Test the new local image and check that the new conf is there

$ docker run --name moodle-web-82-test-posix -p 8888:80 moodlehq/moodle-php-apache:8.2-test-posix
...
[Sun Jan 29 19:24:57.838261 2023] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

$ docker rm -v moodle-web-82-test-posix
$ docker run --rm --name moodle-web-82-test-posix -it moodlehq/moodle-php-apache:8.2-test-posix grep -i mutex /etc/apache2/apache2.conf
# mounted filesystem then please read the Mutex documentation (available
# at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
#Mutex file:${APACHE_LOCK_DIR} default
Mutex posixsem

Remove the test env

$  docker buildx rm
$  docker rmi moodle-web-82-test-posix

HTH, Matteo

mackensen commented 1 year ago

@scara Thanks, I can confirm it built and ran fine on my M1.

stronk7 commented 1 year ago

So maybe we can just try adding this to the Dockerfile (disclaimer, not tested):

...
RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
    sed -i '/^#Mutex.*/a Mutex posixsem' /etc/apache2/apache2.conf; \
    fi

And done?

scara commented 1 year ago

Hi @stronk7,

And done?

Yes: I guess we need the help of @mackensen to perform the end test or just look at the /etc/apache2/apache2.conf file in the resulting arm64 image (an automated test?).

Not sure why @andrewnicols didn't mention this issue when hardly working on https://github.com/moodlehq/moodle-php-apache in these days. Does he run Docker Engine on M1 too?

HTH, Matteo

andrewnicols commented 1 year ago

Yes, both @stronk7 and I use M1 machines. I've not had any issues in the times that I use the docker image.

stronk7 commented 1 year ago

Yes, while I still use an old x64 laptop as main one... I've a 2020 Mini M1 and I use to run stuff there here and there. I've just tried and it's working ok (nothing in logs apart from the requests) and apache serving perfectly ok:

$ bin/moodle-docker-compose exec -u www-data webserver php admin/tool/behat/cli/run.php --tags=@auth_manual
Running single behat site:
Moodle 4.2dev+ (Build: 20230318), f3bf17cdfbee0377f5a09fcbbcce7c0367bbe58b
Php: 8.0.28, pgsql: 13.10 (Debian 13.10-1.pgdg110+1), OS: Linux 5.15.49-linuxkit aarch64
Run optional tests:
- Accessibility: No
Server OS "Linux", Browser: "firefox"
Started at 21-03-2023, 15:02
...............

2 scenarios (2 passed)
15 steps (15 passed)
0m24.00s (51.45Mb)

I'm using latest Docker Desktop 4.17.0 (Engine 20.10.23), with "Use Virtualization framework" and "VirtioFS" enabled.

Ciao :-)

scara commented 1 year ago

Hi @mackensen,

I'm using latest Docker Desktop 4.17.0 (Engine 20.10.23), with "Use Virtualization framework" and "VirtioFS" enabled.

could you share here your configuration to compare it with the others?

TIA, Matteo

mackensen commented 1 year ago

Hi @mackensen,

I'm using latest Docker Desktop 4.17.0 (Engine 20.10.23), with "Use Virtualization framework" and "VirtioFS" enabled.

could you share here your configuration to compare it with the others?

TIA, Matteo

I updated to that version and changed my setting to VirtioFS I'm still seeing the error. The manual compilation workaround is still effective.

stronk7 commented 1 year ago

Hi,

we are really running out of possibilities (and ideas), at very least here. One last thing that may be happening... are you using the very latest moodle-php-apache images? Can you try pulling them manually, for example:

docker pull moodlehq/moodle-php-apache:8.0

(or the version you are using)

If you don't see a message saying "Status: Image is up to date for moodlehq/moodle-php-apache:8.0" it means that you weren't using the latest. If so, just restart all the moodle-docker machinery and try again, please.

Apart from that... I cannot imagine many other causes for the behaviour of your M1, let's see.

Ciao :-)

mackensen commented 1 year ago

@stronk7 that was it, I pulled the latest and the container comes up cleanly now. Thanks!

stronk7 commented 1 year ago

Yay, so we can finally close this one?