I wanted to setup Wordpress / MySQL containers. For that I followed some tutorials and got to this docker-compose.yaml:
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: on-failure:2
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: wordpressroot
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
networks:
- wordpress-web-network
wordpress:
depends_on:
- db
image: wordpress:5.1.1-php7.3-apache
ports:
- "80:80"
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
working_dir: /var/www/html
volumes:
- ./wp-content:/var/www/html/wp-content
networks:
- wordpress-web-network
volumes:
db_data:
networks:
wordpress-web-network:
When starting the containers with docker-compose up -d
the db starts, but crashes while my host gets very laggy because memory consumption goes up greatly. (See attached image)
I tried to analyze and made a small custom Dockerfile with the same base image and observed the same behaviour. The following is the Dockerfile:
FROM mysql:5.7
ENV MYSQL_ROOT_PASSWORD=wordpressroot
ENV MYSQL_DATABASE=wordpress
ENV MYSQL_USER=wordpress
ENV MYSQL_PASSWORD=wordpress
I then ran docker inspect
and saw the following.
"State": {
"Status": "exited",
"Running": false,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 0,
"ExitCode": 137,
"Error": "",
"StartedAt": "2022-05-03T08:19:04.550400109Z",
"FinishedAt": "2022-05-03T08:19:13.304347182Z"
},
It says it wasn’t OOMKilled but the exit code and the hight memory usage are in line with that.
I also tried mysql:5.6 with the same result. What am I doing wrong? Do I have to provide different ENV vars? Or should i purge some of my docker caches?
Edit:
I actually tried the same dockerfile on a different host (also Linux) and there it worked without an issue. This leads me to believe I have to purge something. Once I also had an issue that apt-get didn’t work properly anymore, because some cache was full. I was able to solving it by purging everything. I don’t want to purge everything though. What should I purge?