### Development Setup with Environment Variables Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/configuration.md An example of running a WordPress container for development, specifying database credentials, enabling debug mode, and mapping port 80. This setup uses direct environment variables for configuration. ```bash docker run \ -e WORDPRESS_DB_NAME=wordpress \ -e WORDPRESS_DB_USER=wordpress \ -e WORDPRESS_DB_PASSWORD=password \ -e WORDPRESS_DB_HOST=db \ -e WORDPRESS_DEBUG=1 \ -p 80:80 \ wordpress:latest ``` -------------------------------- ### Download, Verify, and Install WP-CLI Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md This script installs GPG, downloads the WP-CLI phar archive, verifies its GPG signature and SHA512 checksum, sets execute permissions, and cleans up build dependencies. Finally, it verifies the installation by checking the version. ```bash # Install GPG apk add --no-cache --virtual .fetch-deps gnupg # Download signed phar curl -o /usr/local/bin/wp.gpg -fL \ "https://github.com/wp-cli/wp-cli/releases/download/v${WORDPRESS_CLI_VERSION}/wp-cli-${WORDPRESS_CLI_VERSION}.phar.gpg" # Verify GPG signature GNUPGHOME="$(mktemp -d)" gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$WORDPRESS_CLI_GPG_KEY" gpg --batch --decrypt --output /usr/local/bin/wp /usr/local/bin/wp.gpg # Verify SHA512 echo "$WORDPRESS_CLI_SHA512 */usr/local/bin/wp" | sha512sum -c - # Set executable and cleanup chmod +x /usr/local/bin/wp apk del --no-network .fetch-deps # Verify installation wp --allow-root --version ``` -------------------------------- ### Install and Enable PECL Imagick Extension Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Installs the Imagick PECL extension and enables it. Includes cleanup of PECL cache. ```bash pecl install imagick-3.8.1 docker-php-ext-enable imagick rm -r /tmp/pear # Cleanup PECL cache ``` -------------------------------- ### WordPress Installation Check Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/docker-entrypoint-reference.md Checks if WordPress is already installed by looking for `index.php` or `wp-includes/version.php`. If not found, it proceeds to copy WordPress files. ```bash # Detection: Checks if WordPress is installed if [[ ! -e index.php ]] && [[ ! -e wp-includes/version.php ]]; then # Copy WordPress from /usr/src/wordpress to working directory fi ``` -------------------------------- ### Install Core PHP Extensions Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Installs essential PHP extensions, utilizing all available CPU cores for faster compilation. ```bash docker-php-ext-install -j "$(nproc)" \ bcmath # Arbitrary precision arithmetic exif # Image metadata extraction gd # Image generation/manipulation intl # Internationalization functions mysqli # MySQL database driver zip # ZIP file handling ``` -------------------------------- ### Run WP-CLI Help Command Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/docker-entrypoint-reference.md Example of how to run the `help` command using the WP-CLI Docker image, demonstrating the routing logic. ```bash # Enable WP-CLI help routing docker run wordpress:cli help ``` -------------------------------- ### WordPress Download URL Setup Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Sets the environment variable for the WordPress download URL, using a version placeholder that is resolved from versions.json. ```dockerfile ENV WORDPRESS_DOWNLOAD_URL "https://wordpress.org/wordpress-{{ .upstream }}.tar.gz" ``` -------------------------------- ### Kubernetes Readiness Probe Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/integration-guide.md Configure a Kubernetes readiness probe to check for the existence of the wp-config.php file, ensuring the WordPress installation is ready. ```yaml readinessProbe: exec: command: - /bin/sh - -c - "test -f /var/www/html/wp-config.php" initialDelaySeconds: 10 periodSeconds: 5 ``` -------------------------------- ### WordPress Setup for Reverse Proxy Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/configuration.md This snippet shows a basic WordPress Docker setup suitable for use behind a reverse proxy. It directly specifies database credentials as environment variables. Ensure the reverse proxy sets the X-Forwarded-Proto header for correct HTTPS detection. ```bash docker run \ -e WORDPRESS_DB_HOST=db \ -e WORDPRESS_DB_NAME=wordpress \ -e WORDPRESS_DB_USER=wordpress \ -e WORDPRESS_DB_PASSWORD=password \ wordpress:latest # Reverse proxy must set X-Forwarded-Proto header for HTTPS detection ``` -------------------------------- ### WordPress Environment Variables for Installation Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/integration-guide.md Specifies the minimum required environment variables for WordPress to automatically install itself within the container. ```bash -e WORDPRESS_DB_NAME=wordpress -e WORDPRESS_DB_USER=username -e WORDPRESS_DB_PASSWORD=password -e WORDPRESS_DB_HOST=mysql ``` -------------------------------- ### Install WordPress Plugin with CLI Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/image-variants.md Install a WordPress plugin using the WP-CLI Docker image. This requires mounting your WordPress installation directory to the container. ```bash # Install plugin docker run \ -v /var/www/html:/var/www/html \ wordpress:cli plugin install hello ``` -------------------------------- ### Production WordPress Setup with Docker Secrets Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/configuration.md This snippet demonstrates a production-ready WordPress Docker setup. It utilizes environment variables to point to Docker secrets for sensitive information like database credentials and security keys, enhancing security. The health check command ensures the container is running correctly. ```bash docker run \ -e WORDPRESS_DB_NAME_FILE=/run/secrets/db_name \ -e WORDPRESS_DB_USER_FILE=/run/secrets/db_user \ -e WORDPRESS_DB_PASSWORD_FILE=/run/secrets/db_pass \ -e WORDPRESS_DB_HOST=db.internal \ -e WORDPRESS_DB_CHARSET=utf8mb4 \ -e WORDPRESS_TABLE_PREFIX=prod_ \ -e WORDPRESS_AUTH_KEY_FILE=/run/secrets/auth_key \ -e WORDPRESS_SECURE_AUTH_KEY_FILE=/run/secrets/secure_auth_key \ -e WORDPRESS_LOGGED_IN_KEY_FILE=/run/secrets/logged_in_key \ -e WORDPRESS_NONCE_KEY_FILE=/run/secrets/nonce_key \ -e WORDPRESS_AUTH_SALT_FILE=/run/secrets/auth_salt \ -e WORDPRESS_SECURE_AUTH_SALT_FILE=/run/secrets/secure_auth_salt \ -e WORDPRESS_LOGGED_IN_SALT_FILE=/run/secrets/logged_in_salt \ -e WORDPRESS_NONCE_SALT_FILE=/run/secrets/nonce_salt \ --health-cmd='curl -f http://localhost/ || exit 1' \ --health-interval=30s \ wordpress:latest ``` -------------------------------- ### Check WordPress Installation Status Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/docker-entrypoint-reference.md List the contents of the WordPress document root to verify the installation status. This helps confirm that WordPress files have been correctly copied or are present. ```bash docker run --entrypoint bash wordpress:latest -c 'ls -la /var/www/html/' ``` -------------------------------- ### Execute WP-CLI Database Export Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/docker-entrypoint-reference.md Example of executing a WP-CLI database export command using the `wordpress:cli` image. ```bash # Execute wp-cli command docker run wordpress:cli db export ``` -------------------------------- ### CLI Image Dependencies Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Installs system packages required for the CLI variant of the WordPress Docker image. ```shell bash # Required for 'wp shell' command less # Pager for viewing output mysql-client # Database connectivity ``` -------------------------------- ### Usage Examples for getenv_docker() Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/wp-config-docker-reference.md Demonstrates how to use the getenv_docker() function to define WordPress constants, prioritizing environment variables with a _FILE suffix, then direct environment variables, and finally falling back to a default value. ```php // Try WORDPRESS_DB_PASSWORD_FILE first, then WORDPRESS_DB_PASSWORD, then use default define('DB_PASSWORD', getenv_docker('WORDPRESS_DB_PASSWORD', 'example password')); // Try WORDPRESS_DB_HOST_FILE first, then WORDPRESS_DB_HOST, default to 'mysql' define('DB_HOST', getenv_docker('WORDPRESS_DB_HOST', 'mysql')); ``` -------------------------------- ### Run WordPress with PHP-FPM Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/README.md Starts a WordPress container using the PHP-FPM variant. Requires a separate web server (e.g., Nginx or Apache) to handle requests and forward them to the FPM daemon via TCP port 9000. Database connection details are provided via environment variables. ```bash docker run \ -e WORDPRESS_DB_HOST=mysql \ -e WORDPRESS_DB_NAME=wordpress \ -e WORDPRESS_DB_USER=wordpress \ -e WORDPRESS_DB_PASSWORD=password \ wordpress:fpm ``` -------------------------------- ### Docker Compose for WordPress with Apache Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/image-variants.md This setup uses the standard WordPress Apache image for a simple, single-container deployment. It includes a MySQL database service. ```yaml version: '3' services: wordpress: image: wordpress:latest ports: - "80:80" environment: WORDPRESS_DB_HOST: db WORDPRESS_DB_NAME: wordpress WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress volumes: - wordpress:/var/www/html depends_on: - db db: image: mysql:8.0 environment: MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress MYSQL_ROOT_PASSWORD: root volumes: wordpress: ``` -------------------------------- ### Debian Variant System Dependencies Installation Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Installs system packages required for non-CLI WordPress images on Debian-based systems using apt-get. ```shell bash # Required for entrypoint script ghostscript # PDF preview rendering libheif-plugin-aomenc # AV1 video codec encoding libheif-plugin-x265 # HEVC (H.265) encoding ``` -------------------------------- ### WordPress .htaccess Configuration Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Creates a .htaccess file in the WordPress installation directory to enable URL rewriting for pretty permalinks. ```apache # BEGIN WordPress RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress ``` -------------------------------- ### Verify WordPress Installation Files Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/integration-guide.md Check the integrity and presence of WordPress files within the container's web root directory. ```bash # Verify WordPress files docker exec wordpress_container ls -la /var/www/html/ # Check wp-config.php docker exec wordpress_container cat /var/www/html/wp-config.php ``` -------------------------------- ### Docker Compose for FPM + Nginx + MySQL Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/integration-guide.md Defines a Docker Compose setup for running WordPress with FPM, Nginx as a reverse proxy, and MySQL. Includes configuration for Nginx and SSL. ```yaml version: '3.8' services: wordpress: image: wordpress:fpm restart: unless-stopped environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_NAME: wordpress WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress_password volumes: - wordpress_data:/var/www/html depends_on: - db networks: - wordpress-network nginx: image: nginx:alpine restart: unless-stopped ports: - "80:80" - "443:443" volumes: - wordpress_data:/var/www/html - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro - ./ssl:/etc/nginx/ssl:ro depends_on: - wordpress networks: - wordpress-network db: image: mysql:8.0 restart: unless-stopped environment: MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress_password MYSQL_ROOT_PASSWORD: root_password volumes: - db_data:/var/lib/mysql networks: - wordpress-network wordpress_cli: image: wordpress:cli environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_NAME: wordpress WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress_password volumes: - wordpress_data:/var/www/html depends_on: - db networks: - wordpress-network # Run only when needed: docker-compose run wordpress_cli command volumes: wordpress_data: db_data: networks: wordpress-network: ``` -------------------------------- ### Run WordPress with Multiple Named Volumes Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/integration-guide.md Runs a WordPress container using multiple named volumes for fine-grained control over different parts of the installation. Not recommended for standard use. ```bash docker run \ -v wordpress_core:/var/www/html/wp-admin \ -v wordpress_core:/var/www/html/wp-includes \ -v wordpress_content:/var/www/html/wp-content \ -v wordpress_config:/var/www/html/wp-config.php \ wordpress:latest ``` -------------------------------- ### Alpine Variant System Dependencies Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Installs system packages required for non-CLI WordPress images on Alpine Linux using apk. ```shell bash # Required for entrypoint script ghostscript # PDF preview rendering imagemagick # Image processing library ``` -------------------------------- ### Docker Compose for Apache with MySQL Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/integration-guide.md Defines a Docker Compose setup for running WordPress with Apache and a MySQL database, including persistent volumes and network configuration. ```yaml version: '3.8' services: wordpress: image: wordpress:latest restart: unless-stopped ports: - "80:80" environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_NAME: wordpress WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress_password WORDPRESS_DEBUG: '1' volumes: - wordpress_data:/var/www/html depends_on: - db networks: - wordpress-network db: image: mysql:8.0 restart: unless-stopped environment: MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress_password MYSQL_ROOT_PASSWORD: root_password volumes: - db_data:/var/lib/mysql networks: - wordpress-network healthcheck: test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] timeout: 20s retries: 10 volumes: wordpress_data: db_data: networks: wordpress-network: ``` -------------------------------- ### Docker Compose for WordPress with Alpine FPM and Nginx Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/image-variants.md This setup utilizes the smaller WordPress FPM Alpine image for resource-constrained environments or when aiming for reduced image size. It pairs with an Nginx service. ```yaml version: '3' services: wordpress: image: wordpress:fpm-alpine # (same as FPM setup above) nginx: image: nginx:alpine # (same as FPM setup above) db: image: mysql:8.0 # (same as above) volumes: wordpress: ``` -------------------------------- ### Alpine Runtime Dependency Resolution Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Uses scanelf to detect runtime dependencies and installs only needed libraries on Alpine Linux. ```bash runDeps="$(\ scanelf --needed --nobanner --format '%n#p' --recursive "$extDir" \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }')" apk add --no-network --virtual .wordpress-phpexts-rundeps $runDeps apk del --no-network .build-deps ``` -------------------------------- ### Run WordPress with Single Named Volume Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/integration-guide.md Runs a WordPress container using a single named volume for persistent storage of the entire installation. ```bash docker run \ -v wordpress_data:/var/www/html \ wordpress:latest ``` -------------------------------- ### Set Default Command for Apache Variant Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Specifies the default command to run when the container starts for the Apache variant. It launches the Apache web server in the foreground. ```dockerfile CMD ["apache2-foreground"] ``` -------------------------------- ### Database User Configuration Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/wp-config-docker-reference.md Defines the database user using the getenv_docker() helper function. It prioritizes the WORDPRESS_DB_USER environment variable (or WORDPRESS_DB_USER_FILE) and defaults to 'example username'. Production deployments must provide actual credentials. ```php define( 'DB_USER', getenv_docker('WORDPRESS_DB_USER', 'example username') ); ``` -------------------------------- ### Set WordPress File Ownership Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Sets the ownership of the WordPress installation directory to the web server user (www-data) for proper file access. ```bash chown -R www-data:www-data /usr/src/wordpress ``` -------------------------------- ### Set Default Command for FPM Variants Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Specifies the default command to run when the container starts for the PHP-FPM variants. It launches the PHP-FPM process. ```dockerfile CMD ["php-fpm"] ``` -------------------------------- ### Run Shell Command Directly Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/docker-entrypoint-reference.md Example of executing a standard shell command like `bash` directly using the `wordpress:cli` image, bypassing WP-CLI routing. ```bash # Run shell command directly docker run wordpress:cli bash ``` -------------------------------- ### Capture WORDPRESS_* Environment Variables Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/docker-entrypoint-reference.md Captures all environment variables that start with `WORDPRESS_` into a bash array named `wpEnvs`. This is used to dynamically configure WordPress based on environment settings. ```bash wpEnvs=( "${!WORDPRESS_@}" ) # Array of all WORDPRESS_* vars ``` -------------------------------- ### WP-CLI Command Routing Logic Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/docker-entrypoint-reference.md Determines whether to prepend the `wp` command based on the first argument. It checks if the argument is an option flag (starts with `-`) or a valid WP-CLI subcommand. ```bash if [ "${1#-}" != "$1" ] || wp help "$1" > /dev/null 2>&1; then set -- wp "$@" fi exec "$@" ``` -------------------------------- ### Database Password Configuration Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/wp-config-docker-reference.md Defines the database password using the getenv_docker() helper function. It prioritizes the WORDPRESS_DB_PASSWORD environment variable (or WORDPRESS_DB_PASSWORD_FILE) and defaults to 'example password'. This should always be provided via environment or Docker secrets in production. ```php define( 'DB_PASSWORD', getenv_docker('WORDPRESS_DB_PASSWORD', 'example password') ); ``` -------------------------------- ### Docker Compose for WordPress with FPM and Nginx Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/image-variants.md This configuration uses the WordPress FPM image with a separate Nginx service for serving the application. It's suitable for more complex setups or when using orchestration tools. ```yaml version: '3' services: wordpress: image: wordpress:fpm environment: WORDPRESS_DB_HOST: db WORDPRESS_DB_NAME: wordpress WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress volumes: - wordpress:/var/www/html depends_on: - db nginx: image: nginx:latest ports: - "80:80" volumes: - wordpress:/var/www/html - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro depends_on: - wordpress db: image: mysql:8.0 environment: MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress MYSQL_ROOT_PASSWORD: root volumes: wordpress: ``` -------------------------------- ### Execute Custom PHP Configuration Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/wp-config-docker-reference.md Allows for additional WordPress constants and configurations to be set via the WORDPRESS_CONFIG_EXTRA environment variable. The content of this variable is executed as PHP code using eval(), providing flexibility for custom setups. Use with caution as it executes arbitrary PHP code. ```php if ($configExtra = getenv_docker('WORDPRESS_CONFIG_EXTRA', '')) { eval($configExtra); } ``` ```bash # Set memory limits -e WORDPRESS_CONFIG_EXTRA=' define("WP_MEMORY_LIMIT", "256M"); define("WP_MAX_MEMORY_LIMIT", "512M"); ' # Disable automatic updates -e WORDPRESS_CONFIG_EXTRA=' define("AUTOMATIC_UPDATER_DISABLED", true); ' # Configure WordPress constants -e WORDPRESS_CONFIG_EXTRA=' define("WP_HOME", "https://example.com"); define("WP_SITEURL", "https://example.com"); define("DISALLOW_FILE_EDIT", true); ' ``` -------------------------------- ### Enable Detailed Output with Bash Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/docker-entrypoint-reference.md Run the entrypoint script with 'set -x' to enable detailed execution tracing. This is useful for debugging script behavior. ```bash #!/bin/bash docker run --entrypoint bash wordpress:latest -c 'set -x; /usr/local/bin/docker-entrypoint.sh php-fpm' ``` -------------------------------- ### Entrypoint and CMD for Apache/FPM Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md Sets the entrypoint script and the default command for running the Apache or PHP-FPM service in the foreground. ```dockerfile ENTRYPOINT ["docker-entrypoint.sh"] CMD ["apache2-foreground"] # or php-fpm ``` -------------------------------- ### Load WordPress Settings Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/wp-config-docker-reference.md Loads the core WordPress files and initializes the WordPress environment. This line must be the last in the wp-config.php file. ```php require_once ABSPATH . 'wp-settings.php'; ``` -------------------------------- ### Create and Set Permissions for WordPress Directory Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Initializes the WordPress web root directory and sets appropriate ownership for the web server user. ```shell mkdir -p /var/www/html chown -R www-data:www-data /var/www/html ``` -------------------------------- ### Apply-templates.sh: Copying non-CLI related files Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md For non-CLI WordPress variants (latest/beta), `apply-templates.sh` copies the `docker-entrypoint.sh` and `wp-config-docker.php` scripts into the generated version directory. ```bash cp -a docker-entrypoint.sh wp-config-docker.php "$dir/" ``` -------------------------------- ### Get Git Commit Hash Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md Shell function to retrieve the latest Git commit hash for a given file or directory. ```bash fileCommit() { git log -1 --format='format:%H' HEAD -- "$@" } dirCommit() { # Get latest commit for Dockerfile and all COPY'd files } ``` -------------------------------- ### Apply-templates.sh: Copying CLI related files Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md For the WP-CLI variant, `apply-templates.sh` copies the `cli-entrypoint.sh` script and renames it to `docker-entrypoint.sh` within the generated directory. ```bash cp -a cli-entrypoint.sh "$dir/docker-entrypoint.sh" ``` -------------------------------- ### Single-Container Development with Apache Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/README.md Launches a WordPress site using the Apache variant in a single container for simple development environments. It maps port 80 of the container to port 80 on the host and requires database host information. ```bash docker run -p 80:80 -e WORDPRESS_DB_HOST=mysql wordpress:latest ``` -------------------------------- ### Debian Variant APT Cache Cleanup Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Cleans up the APT cache after installing packages to reduce the final Docker image size. ```shell apt-get update apt-get install -y --no-install-recommends [packages] rm -rf /var/lib/apt/lists/* # Clean cache for smaller image ``` -------------------------------- ### Use WP-CLI with Option Flags Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/docker-entrypoint-reference.md Demonstrates how to use WP-CLI commands with option flags (e.g., `--info`, `--version`) via the `wordpress:cli` image, showing the routing logic in action. ```bash # Use WP-CLI with option flags docker run wordpress:cli --info docker run wordpress:cli --version ``` -------------------------------- ### Create and Set Permissions for wp-content Directory Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md This snippet creates the wp-content directory, sets up subdirectories including 'cache', and then applies ownership and permissions. It's used to prepare the directory structure before potential bind-mounting of themes or plugins. ```bash mkdir wp-content for dir in /usr/src/wordpress/wp-content/*/ cache; do dir="$(basename "${dir%/}")" mkdir "wp-content/$dir" done chown -R www-data:www-data wp-content chmod -R 1777 wp-content ``` -------------------------------- ### Generate Security Keys with awk Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/wp-config-docker-reference.md This script snippet demonstrates how the docker-entrypoint.sh script uses awk to find and replace placeholders for security keys with randomly generated SHA1 hashes. ```bash awk \ '/put your unique phrase here/ { cmd = "head -c1m /dev/urandom | sha1sum | cut -d\\ -f1" cmd | getline str close(cmd) gsub("put your unique phrase here", str) } { print }' ``` -------------------------------- ### Get Parent Image Architectures Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md Shell function to extract parent image information and query official-images for its architectures, caching the results. ```bash getArches() { # Extract parent image from FROM line # Query official-images for architectures # Cache results in associative array } ``` -------------------------------- ### Create WordPress User with CLI Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/image-variants.md Create a new WordPress user with a specified role using the WP-CLI Docker image. Database connection details must be provided via environment variables. ```bash # Create user docker run \ -e WORDPRESS_DB_HOST=db \ wordpress:cli user create admin admin@example.com --role=administrator ``` -------------------------------- ### Import WordPress Database to New Container Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/integration-guide.md Use the WordPress CLI image to import a SQL backup file into a new WordPress database container. ```bash # Using CLI image docker run \ --rm \ -e WORDPRESS_DB_HOST=new-db:3306 \ -e WORDPRESS_DB_NAME=wordpress \ -e WORDPRESS_DB_USER=wordpress \ -e WORDPRESS_DB_PASSWORD=password \ -i \ wordpress:cli \ db import - < backup.sql ``` -------------------------------- ### Database Export using WP-CLI Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/README.md Demonstrates how to export the WordPress database to a file using the WP-CLI Docker image. This command is typically run to create a backup of the database. ```bash docker run wordpress:cli db export > backup.sql ``` -------------------------------- ### Run versions.sh to update all versions Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md Execute the `versions.sh` script without arguments to update all WordPress and WP-CLI versions, including latest, beta, and CLI, and regenerate the `versions.json` metadata file. ```bash ./versions.sh ``` -------------------------------- ### Set Default Command for CLI Variant Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Sets the user to 'www-data' and specifies the default command to start an interactive WP-CLI shell for the CLI variant. ```dockerfile USER www-data CMD ["wp", "shell"] ``` -------------------------------- ### Entrypoint and CMD for CLI Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md Configures the entrypoint script and sets the default command to 'wp shell' for the WP-CLI variant, running as the www-data user. ```dockerfile ENTRYPOINT ["docker-entrypoint.sh"] USER www-data CMD ["wp", "shell"] ``` -------------------------------- ### Test WordPress Database Connectivity Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/integration-guide.md Use the WordPress CLI to check the database connection and list available tables. ```bash # Test database connectivity docker exec wordpress_container \ wp db check # Check tables docker exec wordpress_container \ wp db tables ``` -------------------------------- ### Configure Database with Environment Variables Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/configuration.md Use direct environment variables to set database connection details when running a WordPress container. Ensure these variables match your database server configuration. ```bash docker run \ -e WORDPRESS_DB_NAME=mydb \ -e WORDPRESS_DB_USER=wpuser \ -e WORDPRESS_DB_PASSWORD=secretpass \ -e WORDPRESS_DB_HOST=db.example.com \ wordpress:latest ``` -------------------------------- ### Set Docker Entrypoint Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Configures the primary executable for the container. All variants use the 'docker-entrypoint.sh' script as their entrypoint. ```dockerfile ENTRYPOINT ["docker-entrypoint.sh"] ``` -------------------------------- ### WordPress CLI Interactive Shell Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/image-variants.md Use this command to start an interactive WP-CLI shell within the WordPress CLI Docker container. This is useful for running multiple WP-CLI commands in sequence. ```bash # Interactive shell docker run -it wordpress:cli wp shell ``` -------------------------------- ### Verify wp-config.php Generation Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/docker-entrypoint-reference.md Inspect the generated wp-config.php file to ensure database credentials and other configurations are correctly set. This command requires database environment variables to be provided. ```bash docker run \ -e WORDPRESS_DB_NAME=testdb \ wordpress:latest \ cat /var/www/html/wp-config.php ``` -------------------------------- ### Kubernetes Liveness Probe Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/integration-guide.md Configure a Kubernetes liveness probe to check for the existence of index.php, preventing stuck WordPress containers. ```yaml livenessProbe: exec: command: - /bin/sh - -c - "test -f /var/www/html/index.php" initialDelaySeconds: 60 periodSeconds: 30 ``` -------------------------------- ### Debian Build Dependency Cleanup Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Cleans up build dependencies on Debian-based systems. It saves manually installed packages, analyzes shared library dependencies, removes build-only dependencies, and cleans the package cache. ```bash apt-mark auto '.*' > /dev/null apt-mark manual $savedAptMark # Keep originally installed packages ldd "$extDir"/*.so | awk '/=>/ { ... }' | xargs -r dpkg-query --search | ... apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false rm -rf /var/lib/apt/lists/* ``` -------------------------------- ### Update Script Execution Flow Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md Demonstrates the sequential execution flow of the update.sh script, calling other build scripts in order. ```bash #!/usr/bin/env bash set -Eeuo pipefail cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" ./versions.sh "$@" ./apply-templates.sh "$@" ./generate-stackbrew-library.sh "$@" ``` -------------------------------- ### Full Build Pipeline Orchestration Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md Executes the main update.sh script to run the entire build pipeline, including version fetching, Dockerfile generation, and library file creation. ```bash # Full update cycle ./update.sh ``` -------------------------------- ### Set Database Table Prefix Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/wp-config-docker-reference.md Defines the database table prefix for WordPress. It reads the prefix from the WORDPRESS_TABLE_PREFIX environment variable, defaulting to 'wp_' if not set. This setting must be defined before WordPress creates its database tables and allows for multiple WordPress installations within a single database. ```php $table_prefix = getenv_docker('WORDPRESS_TABLE_PREFIX', 'wp_'); ``` -------------------------------- ### Apply Dockerfile templates for specific versions Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md Execute `apply-templates.sh` with specific version arguments to process only those versions. If no arguments are provided, it processes all versions defined in `versions.json`. ```bash apply-templates.sh [version ...] ``` -------------------------------- ### Basic WordPress Apache Variant Execution Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/README.md Run the WordPress container using the Apache variant, exposing port 80 and providing essential database configuration via environment variables. ```bash docker run \ -p 80:80 \ -e WORDPRESS_DB_HOST=mysql \ -e WORDPRESS_DB_NAME=wordpress \ -e WORDPRESS_DB_USER=wordpress \ -e WORDPRESS_DB_PASSWORD=password \ wordpress:latest ``` -------------------------------- ### Optimize WordPress Database via CLI Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/integration-guide.md Use the WordPress CLI to optimize the database tables within a running WordPress container. ```bash # Run database optimization docker exec wordpress_container \ wp db optimize ``` -------------------------------- ### Execute Command with Process Replacement Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/docker-entrypoint-reference.md Replaces the current shell process with the command specified as an argument to the entrypoint script. This is the final step after initialization. ```bash exec "$@" ``` -------------------------------- ### View Generated Library Entry Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md Displays the first 20 lines of the generated library file for the 'latest' tag, useful for reviewing the output of generate-stackbrew-library.sh. ```bash ./generate-stackbrew-library.sh latest | head -20 ``` -------------------------------- ### Run WP-CLI for Database Export Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/README.md Executes the WordPress Command-Line Interface (WP-CLI) to perform a database export. This is useful for backups or migrating database content. Database connection details must be provided via environment variables. ```bash docker run \ -e WORDPRESS_DB_HOST=mysql \ -e WORDPRESS_DB_NAME=wordpress \ -e WORDPRESS_DB_USER=wordpress \ -e WORDPRESS_DB_PASSWORD=password \ wordpress:cli db export ``` -------------------------------- ### Kubernetes Deployment for WordPress Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/integration-guide.md This Kubernetes Deployment defines how to run the WordPress FPM container, including environment variables for database connection and security keys, volume mounts for storage, and health probes. ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: wordpress labels: app: wordpress spec: replicas: 2 selector: matchLabels: app: wordpress template: metadata: labels: app: wordpress spec: containers: - name: wordpress image: wordpress:fpm-alpine imagePullPolicy: Always ports: - containerPort: 9000 protocol: TCP env: - name: WORDPRESS_DB_HOST value: mysql:3306 - name: WORDPRESS_DB_NAME valueFrom: secretKeyRef: name: wordpress-secrets key: db-name - name: WORDPRESS_DB_USER valueFrom: secretKeyRef: name: wordpress-secrets key: db-user - name: WORDPRESS_DB_PASSWORD valueFrom: secretKeyRef: name: wordpress-secrets key: db-password - name: WORDPRESS_AUTH_KEY valueFrom: secretKeyRef: name: wordpress-secrets key: auth-key - name: WORDPRESS_SECURE_AUTH_KEY valueFrom: secretKeyRef: name: wordpress-secrets key: secure-auth-key - name: WORDPRESS_LOGGED_IN_KEY valueFrom: secretKeyRef: name: wordpress-secrets key: logged-in-key - name: WORDPRESS_NONCE_KEY valueFrom: secretKeyRef: name: wordpress-secrets key: nonce-key - name: WORDPRESS_AUTH_SALT valueFrom: secretKeyRef: name: wordpress-secrets key: auth-salt - name: WORDPRESS_SECURE_AUTH_SALT valueFrom: secretKeyRef: name: wordpress-secrets key: secure-auth-salt - name: WORDPRESS_LOGGED_IN_SALT valueFrom: secretKeyRef: name: wordpress-secrets key: logged-in-salt - name: WORDPRESS_NONCE_SALT valueFrom: secretKeyRef: name: wordpress-secrets key: nonce-salt volumeMounts: - name: wordpress-storage mountPath: /var/www/html livenessProbe: exec: command: - /bin/sh - -c - "cd /var/www/html && test -f wp-config.php" initialDelaySeconds: 30 periodSeconds: 10 readinessProbe: exec: command: - /bin/sh - -c - "cd /var/www/html && test -f wp-config.php" initialDelaySeconds: 5 periodSeconds: 5 volumes: - name: wordpress-storage persistentVolumeClaim: claimName: wordpress-pvc --- apiVersion: v1 kind: Service metadata: name: wordpress spec: selector: app: wordpress ports: - protocol: TCP port: 9000 targetPort: 9000 type: ClusterIP --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: wordpress-pvc spec: accessModes: - ReadWriteMany resources: requests: storage: 10Gi storageClassName: standard --- apiVersion: v1 kind: Secret metadata: name: wordpress-secrets type: Opaque stringData: db-name: wordpress db-user: wordpress db-password: secure_password_here auth-key: random_key_1 secure-auth-key: random_key_2 logged-in-key: random_key_3 nonce-key: random_key_4 auth-salt: random_salt_1 secure-auth-salt: random_salt_2 logged-in-salt: random_salt_3 nonce-salt: random_salt_4 ``` -------------------------------- ### Main Entrypoint Script Signature Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/docker-entrypoint-reference.md Defines the standard signature for the main Docker entrypoint script, enabling extended options and error checking. ```bash #!/usr/bin/env bash set -Eeuo pipefail docker-entrypoint.sh [COMMAND] ``` -------------------------------- ### Generate All Dockerfile Versions Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md Executes the apply-templates.sh script to generate all Dockerfiles based on the defined versions. ```bash # Generate all versions ./apply-templates.sh ``` -------------------------------- ### Define WordPress Image Test Case Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md Specifies a test case for the wordpress:apache image within the test configuration file. This ensures the 'wordpress-ensure-installed' test is run for this image. ```bash imageTests[wordpress:apache]+='\n wordpress-ensure-installed\n' ``` -------------------------------- ### Check for Latest Versions Script Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md Executes the versions.sh script to fetch the latest stable, beta, and CLI versions of WordPress. The output indicates the detected versions. ```bash ./versions.sh # Outputs: latest: 7.0.0, beta: 7.0.0, cli: 2.12.0 ``` -------------------------------- ### WordPress Image Tags by PHP Version Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/image-variants.md Illustrates the tagging convention for WordPress Docker images, showing how to select specific PHP versions and web server configurations (Apache, FPM, FPM-Alpine). ```text # Default (PHP 8.3 + Apache) wordpress:latest wordpress:7.0.0 # PHP 8.2 Apache wordpress:7.0.0-php8.2-apache wordpress:php8.2 # PHP 8.3 FPM wordpress:7.0.0-fpm-php8.3 wordpress:fpm-php8.3 # PHP 8.4 FPM-Alpine wordpress:7.0.0-fpm-alpine-php8.4 wordpress:fpm-alpine-php8.4 # PHP 8.5 CLI wordpress:cli-php8.5 ``` -------------------------------- ### WordPress Configuration Check Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/docker-entrypoint-reference.md Checks if `wp-config.php` exists and if any `WORDPRESS_*` environment variables are set. If `wp-config.php` is missing and variables are present, it proceeds to generate the configuration file. ```bash # Detection: Checks if wp-config.php exists and WORDPRESS_* variables are set if [[ ! -s wp-config.php ]] && [[ "${#wpEnvs[@]}" -gt 0 ]]; then # Generate wp-config.php from wp-config-docker.php fi ``` -------------------------------- ### Generate Stackbrew Library Output Format Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md Illustrates the expected output format for the official-images library file, including tags, architectures, commit hash, and directory. ```text Tags: 7.0.0, 7.0, 7, latest, apache, 7.0.0-apache, 7.0-apache, 7-apache, latest-apache, 7.0.0-php8.3, 7.0-php8.3, 7-php8.3, php8.3, 7.0.0-php8.3-apache, 7.0-php8.3-apache, 7-php8.3-apache, php8.3-apache Architectures: amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, s390x GitCommit: e50bb75667ecaa0eac0694fb3c7b024afc96fde0 Directory: latest/php8.3/apache ``` -------------------------------- ### Run versions.sh to update specific versions Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md Specify version types like 'cli', 'latest', or 'beta' as arguments to `versions.sh` to update only those specific versions and merge them into the existing `versions.json`. ```bash ./versions.sh cli ``` ```bash ./versions.sh latest beta ``` -------------------------------- ### Essential Environment Variables for Database Configuration Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/README.md Configure database connection details using environment variables. These are required for WordPress to connect to its database. ```bash -e WORDPRESS_DB_HOST=mysql -e WORDPRESS_DB_NAME=wordpress -e WORDPRESS_DB_USER=wordpress -e WORDPRESS_DB_PASSWORD=secret ``` -------------------------------- ### Environment Variables for Security Keys Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/README.md Set security keys for authentication and nonces. These are auto-generated if not provided, but explicit definition enhances security. ```bash -e WORDPRESS_AUTH_KEY=unique_key -e WORDPRESS_SECURE_AUTH_KEY=unique_key -e WORDPRESS_LOGGED_IN_KEY=unique_key -e WORDPRESS_NONCE_KEY=unique_key -e WORDPRESS_AUTH_SALT=unique_salt -e WORDPRESS_SECURE_AUTH_SALT=unique_salt -e WORDPRESS_LOGGED_IN_SALT=unique_salt -e WORDPRESS_NONCE_SALT=unique_salt ``` -------------------------------- ### Enable Apache Modules Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Enables essential Apache modules for WordPress functionality, including URL rewriting, cache expiration, and reverse proxy IP detection. ```bash a2enmod rewrite # URL rewriting (required for WordPress) a2enmod expires # Cache expiration headers a2enmod remoteip # Reverse proxy IP detection ``` -------------------------------- ### WordPress Configuration Template Search Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/docker-entrypoint-reference.md Searches for the `wp-config-docker.php` template file, first in the current directory and then falls back to the default location within the WordPress source. ```bash # Looks for `wp-config-docker.php` in current directory # Falls back to `/usr/src/wordpress/wp-config-docker.php` ``` -------------------------------- ### Generate New Dockerfiles Script Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md Runs the apply-templates.sh script to regenerate all Dockerfiles based on the current version information and templates. ```bash ./apply-templates.sh ``` -------------------------------- ### Configure GD Library with Image Formats Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/configuration.md This command configures the GD library to support various image formats including AVIF, JPEG, WebP, and Freetype fonts. This is typically used within a Dockerfile to enable specific image processing capabilities. ```bash docker-php-ext-configure gd \ --with-avif \ --with-freetype \ --with-jpeg \ --with-webp ``` -------------------------------- ### Copy Entrypoint Script Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Copies the docker-entrypoint.sh script to the /usr/local/bin directory. For non-CLI variants, it also creates a symbolic link to this script, providing an alternative invocation method. ```dockerfile COPY docker-entrypoint.sh /usr/local/bin/ # For non-CLI only: RUN ln -svfT docker-entrypoint.sh /usr/local/bin/docker-ensure-installed.sh ``` -------------------------------- ### Apply-templates.sh: Directory structure generation Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md This snippet shows the directory structure created by `apply-templates.sh` for each processed WordPress version. It includes subdirectories for different PHP versions and variants like 'apache' and 'fpm'. ```bash version/ ├── php8.2/ │ ├── apache/ │ │ ├── Dockerfile │ │ ├── docker-entrypoint.sh │ │ └── wp-config-docker.php │ ├── fpm/ │ │ ├── Dockerfile │ │ ├── docker-entrypoint.sh │ │ └── wp-config-docker.php │ └── fpm-alpine/ │ ├── Dockerfile │ ├── docker-entrypoint.sh │ └── wp-config-docker.php ├── php8.3/ ├── php8.4/ └── php8.5/ ``` -------------------------------- ### Database Host Configuration Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/wp-config-docker-reference.md Defines the database host using the getenv_docker() helper function. It prioritizes the WORDPRESS_DB_HOST environment variable (or WORDPRESS_DB_HOST_FILE) and defaults to 'mysql'. The host can be a hostname or IP address, optionally with a port. ```php define( 'DB_HOST', getenv_docker('WORDPRESS_DB_HOST', 'mysql') ); ``` -------------------------------- ### Pull and Run WordPress Container Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/integration-guide.md Pulls the latest WordPress image and runs it, mapping port 80 and setting essential database environment variables. ```bash # Pull latest Apache image docker pull wordpress:latest # Run with MySQL database docker run \ -p 80:80 \ -e WORDPRESS_DB_HOST=mysql \ -e WORDPRESS_DB_USER=wordpress \ -e WORDPRESS_DB_PASSWORD=password \ wordpress:latest ``` -------------------------------- ### Set Environment Variables for WP-CLI Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Sets environment variables required for downloading and verifying the WP-CLI. This includes the GPG key, version, and SHA512 checksum. ```dockerfile ENV WORDPRESS_CLI_GPG_KEY 63AF7AA15067C05616FDDD88A3A2E8F226F0BC06 ENV WORDPRESS_CLI_VERSION {{ .version }} ENV WORDPRESS_CLI_SHA512 {{ .sha512 }} ``` -------------------------------- ### PHP OPcache Configuration Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/configuration.md Sets recommended OPcache settings for PHP-FPM and Apache variants to improve performance. Note that these settings are excluded from the CLI variant. ```ini opcache.memory_consumption=128 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=4000 opcache.revalidate_freq=2 ``` -------------------------------- ### Default PHP Version and Variant Configuration Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md Specifies the default PHP version and image variant used when not explicitly provided. ```bash defaultPhpVersion='php8.3' defaultVariant='apache' ``` -------------------------------- ### Download and Verify WordPress Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Downloads the WordPress tarball and verifies its integrity using a SHA1 checksum. ```bash curl -o wordpress.tar.gz -fL "https://wordpress.org/wordpress-$version.tar.gz" echo "$sha1 *wordpress.tar.gz" | sha1sum -c - ``` -------------------------------- ### Enable WordPress Debug Logging Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/integration-guide.md Enable debug logging for WordPress by setting the WORDPRESS_DEBUG environment variable. ```bash docker run \ -e WORDPRESS_DEBUG=1 \ wordpress:latest View logs: ```bash docker logs container_name ``` ``` -------------------------------- ### Using Docker Secrets for Sensitive Data Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/configuration.md Demonstrates how to use Docker secrets to securely provide sensitive information, such as database passwords, to the WordPress container. It shows how to mount a secret file and reference it using an environment variable with a `_FILE` suffix. ```bash # Using Docker secrets docker run \ -e WORDPRESS_DB_PASSWORD_FILE=/run/secrets/db_password wordpress:latest ``` -------------------------------- ### Inspect Generated wp-config.php Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/integration-guide.md View the generated wp-config.php file within the WordPress container to inspect configuration settings. ```bash # View generated wp-config.php docker exec wordpress_container \ grep define /var/www/html/wp-config.php | head -20 ``` -------------------------------- ### Set Working Directory Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/dockerfile-template-reference.md Sets the default working directory for subsequent Dockerfile instructions. ```dockerfile WORKDIR /var/www/html ``` -------------------------------- ### Generate Partial Official Images Library File Source: https://github.com/docker-library/wordpress/blob/master/_autodocs/build-system.md Generates a partial library file for specific versions, useful for targeted updates. ```bash # Generate for specific versions ./generate-stackbrew-library.sh latest cli > partial-library ```