Another short, solution-minded blog post today!
In some cases I run the default WordPress Docker container. But, debugging is always well, a bit more complicated. We can enable WP_DEBUG_LOG
by setting an environment variable: WORDPRESS_DEBUG_LOG
But how do you read, or even better, tail the debug.log file?
Run docker logs -f docker_container_name_or_id > /dev/null
The docker-compose.yml file
version: "3"
services:
db:
container_name: ${NAME}-db
image: mariadb:10.8.2
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_DATABASE: ${DB_NAME}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASSWORD}
volumes:
- "./app/data/db:/var/lib/mysql"
ports:
- "3306"
restart: unless-stopped
wordpress:
container_name: ${NAME}-wordpress
image: "wordpress"
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik_proxy"
- "traefik.http.routers.${NAME}.rule=Host(`${SITE_DOMAIN}`)"
- "traefik.http.routers.${NAME}.tls=true"
volumes:
- "./app/www:/var/www/html/"
links:
- db
networks:
default:
external:
name: traefik_proxy%
The .env file
NAME=third-test
SITE_DOMAIN=third-test.c7
WORDPRESS_ENV=development
DB_NAME=wordpress
DB_USER=wordpress
DB_PASSWORD=password
MYSQL_PASSWORD=password
DB_HOST=db
WP_DEBUG=true
WP_DEBUG_DISPLAY=true
WP_DEBUG_LOG=true
WP_HOME=https://third-test.c7
WP_SITEURL=https://third-test.c7
The command for tailing logs
docker logs -f third-test-wordpress > /dev/null
Happy debugging!
Leave a Reply