Docker: Apache in Apple Silicon M1 - wordpress

I have a docker-compose.yml file:
version: '1'
services:
mariadb:
image: 'docker.io/bitnami/mariadb:10.3-debian-10'
ports:
- '3307:3306'
volumes:
- ./db:/bitnami/mariadb
environment:
- MARIADB_USER=bn_wordpress
- MARIADB_DATABASE=bitnami_wordpress
- ALLOW_EMPTY_PASSWORD=yes
wordpress:
image: 'docker.io/bitnami/wordpress:5-debian-10'
ports:
- '8081:8080'
- '8444:8443'
volumes:
- ./wp:/bitnami/wordpress
depends_on:
- mariadb
environment:
- MARIADB_HOST=mariadb
- MARIADB_PORT_NUMBER=3306
- WORDPRESS_DATABASE_USER=bn_wordpress
- WORDPRESS_DATABASE_NAME=bitnami_wordpress
- ALLOW_EMPTY_PASSWORD=yes
In Mac (Intel) and Linux, I run docker-compose up and it works perfectly.
But in Macbook M1, I installed Docker for Apple Silicon chip and updated rosetta, it prompts this at the end:
wordpress_1 | wordpress 15:48:36.49 INFO ==> ** Starting Apache **
wordpress_1 | [Tue Jul 13 15:48:36.652803 2021] [core:emerg] [pid 1] (95)Operation not supported: AH00023: Couldn't create the mpm-accept mutex
wordpress_1 | (95)Operation not supported: could not create accept mutex
wordpress_1 | AH00015: Unable to open logs
How can I overcome the issue? Appreciate your help!

Running docker compose with platform: linux/amd64 (i.e. running under QEMU) didn't fix this problem for me. Instead (in addition), I had to add:
Mutex posixsem
... to httpd.conf.

A bit late but have you tried adding platform: linux/amd64? Under both mariadb and wordpress

Let me share a summary for quick solution.
Connect to the container as the root user
docker exec -it -u 0 <container_name> /bin/bash
update httpd.conf file
echo "Mutex posixsem" >> /opt/bitnami/apache2/conf/httpd.conf
restart the container
docker restart <container_name>

Related

Wordpress on docker this site cant be reached

So I have setup wordpress on docker this is my yml file configuration:
version: '3.8'
services:
wordpress:
build:
context: .
depends_on:
mysql:
condition: service_healthy
environment:
- WORDPRESS_DEBUG=true
- WORDPRESS_DB_HOST=mysql
- WORDPRESS_DB_USER=wordpress
- WORDPRESS_DB_PASSWORD=password
volumes:
- .:/var/www/html/wp-content/plugins/plugin
ports:
- "8082:80"
mysql:
image: mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=wordpress
- MYSQL_USER=wordpress
- MYSQL_PASSWORD=password
ports:
- "3308:3306"
healthcheck:
test: mysqladmin ping -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD
interval: 1s
timeout: 3s
retries: 30
And this is my Dockerfile:
FROM wordpress:latest
RUN curl -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
&& chmod +x /usr/local/bin/wp
ADD ./bin/ /
RUN chmod +x /*.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]
When I run docker-compose up and go to localhost:8082 I get this This site can’t be reachedlocalhost refused to connect.
Inside wordpress docker logs I see this:
/usr/local/bin/docker-entrypoint.sh: line 99: exec: php-fpm: not found
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.3. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.3. Set the 'ServerName' directive globally to suppress this message
[Mon Oct 17 09:22:49.514781 2022] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.54 (Debian) PHP/7.4.32 configured -- resuming normal operations
[Mon Oct 17 09:22:49.514849 2022] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
172.19.0.1 - - [17/Oct/2022:09:23:42 +0000] "-" 408 0 "-" "-"
Cant find a way to fix it. Would appreciate some help.

Docker container taking 27GB on disk while docker container ls --size only report 500MB

I'm on a Debian VPS on OVH cloud provider, running Docker.
Trying to make an apt update on the instance, I noticed that the disk of 40GB was full. What is quite surprising for an instance hosting 2 Wordpress blogs.
I tried to run:
sudo du -h /var/lib/docker/containers
One of the containers weight 27GB !
27G /var/lib/docker/containers/1618df0(...)d6cc61e
However when I run:
docker container ls --size
The same container only weight 500MB
1618df0(...) 782c(...) "docker-entrypoint.s…" 10 months ago Up 10 months 80/tcp blog_wordpress_1 2B (virtual 545MB)
The Docker Compose is pretty simple:
wordpress:
build:
# call the Dockerfile in ./wordpress
context: ./wordpress
restart: always
environment:
# Connect WordPress to the database
WORDPRESS_DB_HOST: db:xxxx
WORDPRESS_DB_USER: xxxx
WORDPRESS_DB_PASSWORD: xxxx
WORDPRESS_DB_NAME: xxxx
volumes:
# save the content of WordPress an enable local modifications
- ./wordpress/data:/var/www/html
networks:
- traefik
- backend
depends_on:
- db
- redis
The Dockerfile:
FROM wordpress
# printf statement mocks answering the prompts from the pecl install
RUN printf "\n \n" | pecl install redis && docker-php-ext-enable redis
RUN /etc/init.d/apache2 restart
Do you know what to investigate to understand this problem ?
Thanks
Ok, this was actually the logs... The logs are not counted by:
docker container ls --size
So I just truncated the logs, brutally:
sudo sh -c "truncate -s 0 /var/lib/docker/containers/*/*-json.log"
This solve the problem for a while.
For the long term, I added these lines to the Wordpress container's Docker Compose, then deleted and recreated the containers:
logging:
options:
max-size: "10m"
max-file: "3"

nginxproxy/nginx-proxy not resolving VIRTUAL_HOST as expected

I would like to use a reverse proxy with this docker-compose.yml
services:
nginx-proxy:
image: nginxproxy/nginx-proxy
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
depends_on:
- hello-world
hello-world:
image: nginx
ports:
- 9001:80
environment:
VIRTUAL_HOST: hello.world
volumes:
- ./web:/usr/share/nginx/html
What I expect to happen is that curl -H "Host: hello.world" localhost:80 would return the index.html in the folder web. But actually it is return the "Welcome to nginx!" page so it seems it does not resolve the VIRTUAL_HOST at all.
What actually works as expected is the following call: curl -H "Host: hello.world" localhost:9001 which return the index.html as expected. But why cannot it resolve the hostname?. Eventually this is a very minimal example of my setup.
It is running on an arm64 machine with docker version: Docker version 20.10.6, build 370c28948e.
What fundamental mistake am I doing here? I tried to implement it as described on README of the nginx-proxy project.
EDIT:
When I start with docker-compose up -d and then run docker-compose ps I get:
Name Command State Ports
-------------------------------------------------------------------------------------------------------------------
minimal-proxy-example_hello-world_1 /docker-entrypoint.sh ngin ... Up 0.0.0.0:9001->80/tcp,:::9001->80/tcp
minimal-proxy-example_nginx-proxy_1 /app/docker-entrypoint.sh ... Up 0.0.0.0:80->80/tcp,:::80->80/tcp
I am running docker on Arch Linux on a Raspberry Pi 4 using a AArch64 kernel. I tried the same on a normal Amd64 PC with the same result. However I tried also the very same with docker-desktop on Windows 10. I used a git-bash to be able to use curl. And there it all worked as expected! Why does this work on docker-desktop on Windows 10 but not on Arch Linux? As consequence I also posted this question in the Arch Linux forum.
Update
I think the problem relates to this bug: https://github.com/nginx-proxy/nginx-proxy/issues/1548

"doctrine:schema:validate". Message: "An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory"

Can someone educate me on how to run symfony migrations at the shell in a docker container environment?
I login to my app container
$ docker exec -it 79dcd1240fdf /bin/bash
and run
bin/console doctrine:schema:validate
only receive
SQLSTATE[HY000] [2002] No such file or directory
I'm able to login to my database container and access the database from there, so am confused since the db exists?
$ docker exec -it bd96edcb1164 /bin/bash
I have no name!#bd96edcb1164:/$ mysql -h localhost -P 4307 -u andy -ppassword symfony_red
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.23-MariaDB Source distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
MariaDB [symfony_red]> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| symfony_red |
| test |
+--------------------+
3 rows in set (0.001 sec)
MariaDB [symfony_red]>
Here's my docker config:
# docker-compose.yml
version: '2'
services:
myapp:
image: 'docker.io/bitnami/symfony:1-debian-10'
ports:
- '8000:8000'
volumes:
- '.:/app'
depends_on:
- mariadb
mariadb:
image: 'docker.io/bitnami/mariadb:10.3-debian-10'
environment:
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=andy
- MARIADB_DATABASE=symfony_red
- MARIADB_PASSWORD=password
ports:
- "4307:3306"
and my .env config:-
# .env.local
DATABASE_URL=mysql://andy:password#localhost:4307/symfony_red?serverVersion=5.7
I already tried switching 127.0.0.1 to localhost - that just toggles another error:
SQLSTATE[HY000] [2002] Connection refused
help?

Docker: Cannot locate specified Dockerfile error

I want to make a platform for web development on my PC (MacOS) by using docker. After installing nginx in docker container, I wanted to build nginx. I got this error.
Cannot locate specified Dockerfile:nginx.docker
I searched on the Internet, but I cannot solve my problem.
Container information (docker ps -a):
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2f268b825ba3 nginx:latest "nginx -g 'daemon off" 39 minutes ago Up 39 minutes 443/tcp, 0.0.0.0:8081->80/tcp dockertutorial_nginx_1
This is my docker-compose.yml file:
nginx:
container_name: dockertutorial_nginx_1
build: .
dockerfile: nginx.docker
ports:
- 80:8081
links:
- php
volumes:
- .:/Users/user/docker-tutorial
php:
image: php:7.0-fpm
expose:
- 9000
volumes:
- .:/Users/user/docker-tutorial
How can I solve this problem?
I solved it with the location of Dockerfile. The docker cannot find dockerfile. That's why, I got this error. Btw, thanks to #harald Nordgren.

Resources