Skip to content

WORDPRESS_CONFIG_EXTRA does not define WP_ENVIRONMENT_TYPE #973

Closed

Description

@rucomcode

Description:
When trying to set the WordPress environment type via the WORDPRESS_CONFIG_EXTRA environment variable in docker-compose.yml, the constant WP_ENVIRONMENT_TYPE is not defined at runtime if a volume with a local ./wpdata directory is used. Checking via a PHP file shows that the constant is not set.
I am unable to create Application Passwords for local development. The WordPress admin interface does not allow generating Application Passwords when running in this environment, which makes it difficult to test integrations and API access locally.


Minimal docker-compose.yml (sanitized):

services:
  db:
    image: mariadb:latest
    environment:
      MARIADB_DATABASE: wordpress
      MARIADB_USER: wordpress
      MARIADB_PASSWORD: example_password
      MARIADB_ROOT_PASSWORD: example_root_password
    volumes:
      - db_data:/var/lib/mysql
    networks:
      - wordpress_net

  wordpress:
    image: wordpress:latest
    depends_on:
      - db
    ports:
      - "8080:80"
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: example_password
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_CONFIG_EXTRA: |
        define( 'WP_ENVIRONMENT_TYPE', 'development' );
    volumes:
      - ./wpdata:/var/www/html
    networks:
      - wordpress_net

volumes:
  db_data:

networks:
  wordpress_net:
    driver: bridge

Steps to reproduce:

  1. Create a ./wpdata directory (can be empty or contain WordPress files).
  2. Start the containers:
    docker-compose up -d --build --force-recreate
  3. Create a file env-check.php in ./wpdata with the following content:
    <?php
    echo 'WP_ENVIRONMENT_TYPE: ' . (defined('WP_ENVIRONMENT_TYPE') ? WP_ENVIRONMENT_TYPE : 'not defined');
  4. Open http://localhost:8080/env-check.php — the result is: WP_ENVIRONMENT_TYPE: not defined.
  5. Try to create an Application Password in the WordPress admin interface — the option is unavailable for local development.

Expected behavior:
When setting the WORDPRESS_CONFIG_EXTRA environment variable with a define, the constant should be defined at runtime, even if a local volume is mounted.


Versions:

  • WordPress image: wordpress:latest
  • OS: Linux (Manjaro, kernel 6.12.34-1)
  • Browser: any

Additional information:

  • Verified that the environment variable is present inside the container (docker exec wordpress_app printenv WORDPRESS_CONFIG_EXTRA).
 docker exec wordpress_app env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=a802996e310e
WORDPRESS_DB_HOST=db:3306
WORDPRESS_DB_USER=wordpress
WORDPRESS_DB_PASSWORD=your_mariadb_password
WORDPRESS_DB_NAME=wordpress
WORDPRESS_CONFIG_EXTRA=define('WP_ENVIRONMENT_TYPE','development');

Activity

  1. rucomcode commented on Jul 12, 2025

    @rucomcode
    Author

    Just tested it with the FPM container as well — the behavior is the same.

    docker compose exec wordpress env | sort
    WARN[0000] /home/roman/develop/new-docker/new-docker/docker-compose.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion 
    GPG_KEYS=39B641343D8C104B2B146DC3F9C39DC0B9698544 E60913E4DF209907D8E30D96659A97C9CF2A795A 1198C0117593497A5EC5C199286AF1F9897469DC
    HOME=/root
    HOSTNAME=f03e434c5306
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    PHP_ASC_URL=https://www.php.net/distributions/php-8.2.21.tar.xz.asc
    PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
    PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
    PHP_INI_DIR=/usr/local/etc/php
    PHPIZE_DEPS=autoconf            dpkg-dev                file            g++         gcc              libc-dev                make            pkg-config              re2c
    PHP_LDFLAGS=-Wl,-O1 -pie
    PHP_SHA256=8cc44d51bb2506399ec176f70fe110f0c9e1f7d852a5303a2cd1403402199707
    PHP_URL=https://www.php.net/distributions/php-8.2.21.tar.xz
    PHP_VERSION=8.2.21
    WORDPRESS_CONFIG_EXTRA=define('WP_ENVIRONMENT_TYPE', 'development');
    WORDPRESS_DB_HOST=db:3306
    WORDPRESS_DB_NAME=wp_db_8f7g6h
    WORDPRESS_DB_PASSWORD=WpP@ss_9d8f7g
    WORDPRESS_DB_USER=wp_user_3k2j1h
    
    Image
    version: '3.8'
    
    services:
      db:
        image: mariadb:11.3
        container_name: mariadb
        restart: unless-stopped
        environment:
          MYSQL_ROOT_PASSWORD: RooT_2k3j4n8v7s
          MYSQL_DATABASE: wp_db_8f7g6h
          MYSQL_USER: wp_user_3k2j1h
          MYSQL_PASSWORD: WpP@ss_9d8f7g
        volumes:
          - db_data:/var/lib/mysql
        networks:
          - wpnet
    
      wordpress:
        image: wordpress:6.5-fpm
        container_name: wordpress
        restart: unless-stopped
        environment:
          WORDPRESS_DB_HOST: db:3306
          WORDPRESS_DB_NAME: wp_db_8f7g6h
          WORDPRESS_DB_USER: wp_user_3k2j1h
          WORDPRESS_DB_PASSWORD: WpP@ss_9d8f7g
          WORDPRESS_CONFIG_EXTRA: "define('WP_ENVIRONMENT_TYPE', 'development');"
        volumes:
          - wp_data:/var/www/html
        depends_on:
          - db
        networks:
          - wpnet
    
      nginx:
        image: nginx:1.25-alpine
        container_name: nginx
        restart: unless-stopped
        ports:
          - "80:80"
        volumes:
          - ./nginx/conf.d:/etc/nginx/conf.d:ro
          - wp_data:/var/www/html:ro
        depends_on:
          - wordpress
        networks:
          - wpnet
    
    volumes:
      db_data:
      wp_data:
    
    networks:
      wpnet:
        driver: bridge 
    
  2. locked and limited conversation to collaborators on Jul 14, 2025
  3. converted this issue into a discussion #974 on Jul 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions