First: You should probably use the mysql:latest
tag. 5.7 is now an older database, latest is now 8.0.23 (community server).
Second: You should specify wordpress version, and php version and keep these updated along the way. I use image: wordpress:5.6-php7.4-apache
which gives me php7 for better performance.
Once you make changes in your docker-compose.yml, run docker-compose up --build
to make sure to get clean versions of everything.
Your docker-compose version could be upgraded from 3.3 to 3.8 (has nothing to do with performance, though).
Make sure to upgrade your Docker installation to the latest (19.03+ at the moment).
Compare your docker-compose to mine, which is running great with plugins:
version: "3.8"
services:
db:
image: mysql:latest
command: "--default-authentication-plugin=mysql_native_password"
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:5.6-php7.4-apache
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
WORDPRESS_CONFIG_EXTRA: |
define('WP_DEBUG', true);
error_reporting(E_ALL);
ini_set('display_errors', 1);
working_dir: /var/www/html
volumes:
- ./wp-content:/var/www/html/wp-content
- ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
volumes:
db_data: {}
Note that I use working_dir
so that the directory for your docker container is set correctly. By adding wp-content to your volumes you copy wp-content into your container to persist it. Plugins are located in wp-content and this may improve your performance situation.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…