Docker Compose: WORDPRESS_CONFIG_EXTRA
The Docker image for WordPress contains a property called “WORDPRESS_CONFIG_EXTRA”, this allows code to be passed directly to the wp-config.php file. This is great because you can fully customize your WordPress wp-config.php file.
Queryable Variable for Enabling Debug
My normal PHP code will not work:
1 2 3 |
if (isset($_GET['debug']) && $_GET['debug'] == 'debug') { define('WP_DEBUG', true); } |
The trick to getting this code to work is escaping the “$” in Docker. This can easily be done by using double “$$”.
1 2 3 |
if (isset($$_GET['debug']) && $$_GET['debug'] == 'debug') { define('WP_DEBUG', true); } |
Docker Compose File
This attribute can also be utilized in the Docker Compose file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
version: '3.1' services: wordpress: image: wordpress restart: always container_name: wp_hapkidodirectory ports: - 32773:80 volumes: - /mnt/wphost/www/hapkidodirectory.com:/var/www/html/ environment: VIRTUAL_HOST: hapkidodirectory.com, www.hapkidodirectory.com WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: userhkd WORDPRESS_DB_PASSWORD: 'dbpassword' WORDPRESS_DB_NAME: wp_hapkidodirectory WORDPRESS_TABLE_PREFIX: wp_hk_ WORDPRESS_CONFIG_EXTRA: | define('FORCE_SSL_ADMIN', true); if (isset($$_GET['debug']) && $$_GET['debug'] == 'debug') { define('WP_DEBUG', true); } networks: default: external: name: proxynet |