
Custom WordPress Docker image based on the official WordPress image, enhanced with:
The build script uses Docker Buildx to create multi-platform images that work on both Intel/AMD (x86_64) and ARM (Apple Silicon M1/M2/M3, ARM servers) architectures.
wordpress:php{VERSION}-apache image for your specified PHP version/usr/src/wordpress/wp-includes/version.php in that base imageThis ensures your images always match the WordPress versions from the official images.
Note: Different PHP versions may have different WordPress versions. For example:
Ensure Docker Buildx is available (included in Docker Desktop and recent Docker Engine versions):
bashdocker buildx version
Each build creates 8 tags per PHP version, following the official WordPress image naming convention.
WordPress version is automatically detected from the base wordpress:php{VERSION}-apache image.
For example, building PHP 8.3 (which uses wordpress:php8.3-apache as the base) automatically detects the WordPress version and creates:
6.8.3-php8.3-apache (full version with Apache)6.8-php8.3-apache (minor version with Apache)6-php8.3-apache (major version with Apache)php8.3-apache (PHP version only with Apache)6.8.3-php8.3 (full version)6.8-php8.3 (minor version)6-php8.3 (major version)php8.3 (PHP version only)bash# Build with default settings (PHP 8.3, WordPress auto-detected) ./build.sh 8.3 # Build with custom image name ./build.sh 8.3 myrepo/wordpress # Build and push to Docker Hub or registry ./build.sh 8.3 myrepo/wordpress --push # Build and load locally (single platform only) ./build.sh 8.3 myrepo/wordpress --load
bash# Build all PHP versions (WordPress versions auto-detected for each) ./build.sh all myrepo/wordpress # Build all versions and push to registry ./build.sh all myrepo/wordpress --push
This creates 8 tags for each PHP version (7.4, 8.3, 8.4).
Each image supports both linux/amd64 and linux/arm64 platforms.
| Option | Description |
|---|---|
--push | Build and push images to Docker registry (required for multi-platform) |
--load | Build and load into local Docker (single platform only, uses current architecture) |
| (none) | Build only, stores in buildx cache but not in local Docker images |
Note: Multi-platform images cannot be loaded directly into Docker. Use --push to push to a registry, or --load for local testing (single platform).
bash# Build single version make build make build PHP_VERSION=8.3 make build IMAGE_NAME=myrepo/wordpress # Build and push make push IMAGE_NAME=myrepo/wordpress make push-all IMAGE_NAME=myrepo/wordpress # Build and load locally make load PHP_VERSION=8.4 # View all options make help
| Variable | Description | Required | Example |
|---|---|---|---|
MAIL_FROM_DOMAIN | Mail domain for system and Postfix | Yes | yourdomain.com |
POSTFIX_RELAYHOST | SMTP relay host and port | Yes | [smtp.gmail.com]:587 |
POSTFIX_SMTP_USERNAME | SMTP username for authentication | No | user@example.com |
POSTFIX_SMTP_PASSWORD | SMTP password for authentication | No | your-password |
| Variable | Description | Required | Example |
|---|---|---|---|
DKIM_SELECTOR | DKIM selector name | No (enables DKIM if set) |
Note: When DKIM_SELECTOR is set, DKIM signing is automatically enabled. If keys don't exist, they will be generated on first start and the DNS record will be displayed in the logs.
All standard WordPress environment variables are supported. See the https://hub.docker.com/_/wordpress.
On first startup with DKIM enabled, keys will be generated automatically. The DNS record will be displayed in the logs:
bashdocker logs wordpress # Output will include: # ========================================== # DKIM DNS Record # ========================================== # Add this TXT record to your DNS: # # wordpress._domainkey IN TXT ( "v=DKIM1; h=sha256; k=rsa; " # "p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..." ) # # ==========================================
Copy the DNS record and add it to your domain's DNS settings.
To persist DKIM keys across container restarts, mount a volume:
bashdocker run -d \ -v dkim_keys:/etc/opendkim/keys \ -e MAIL_FROM_DOMAIN=yourdomain.com \ -e DKIM_SELECTOR=wordpress \ myrepo/wordpress:php8.3-apache
bashdocker run -d \ --name wordpress \ -p 8080:80 \ -v dkim_keys:/etc/opendkim/keys \ -e MAIL_FROM_DOMAIN='yourdomain.com' \ -e POSTFIX_RELAYHOST='[smtp.gmail.com]:587' \ -e POSTFIX_SMTP_USERNAME='your-email@gmail.com' \ -e POSTFIX_SMTP_PASSWORD='your-app-password' \ -e DKIM_SELECTOR='wordpress' \ -e WORDPRESS_DB_HOST=mysql:3306 \ -e WORDPRESS_DB_USER=wordpress \ -e WORDPRESS_DB_PASSWORD=wordpress \ -e WORDPRESS_DB_NAME=wordpress \ myrepo/wordpress:6.8.3-php8.3-apache # Available tags: # myrepo/wordpress:6.8-php8.3-apache # myrepo/wordpress:6-php8.3-apache # myrepo/wordpress:php8.3-apache # myrepo/wordpress:6.8.3-php8.3 # myrepo/wordpress:php8.3
yamlservices: wordpress: image: myrepo/wordpress:6.8.3-php8.3-apache # Or use any tag: 6.8-php8.3-apache, 6-php8.3-apache, php8.3-apache, etc. ports: - "8080:80" environment: # WordPress database configuration WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress_db_password WORDPRESS_DB_NAME: wordpress # Mail configuration MAIL_FROM_DOMAIN: 'yourdomain.com' # DKIM configuration (optional) DKIM_SELECTOR: 'wordpress' # Postfix relay configuration POSTFIX_RELAYHOST: '[smtp.gmail.com]:587' POSTFIX_SMTP_USERNAME: 'your-email@gmail.com' POSTFIX_SMTP_PASSWORD: 'your-app-password' volumes: - wordpress_data:/var/www/html - dkim_keys:/etc/opendkim/keys depends_on: - db db: image: mysql:8.0 environment: MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress_db_password MYSQL_ROOT_PASSWORD: mysql_root_password volumes: - db_data:/var/lib/mysql volumes: wordpress_data: dkim_keys: db_data:
bashPOSTFIX_RELAYHOST='[smtp.gmail.com]:587' POSTFIX_SMTP_USERNAME='your-email@gmail.com' POSTFIX_SMTP_PASSWORD='your-app-password'
Note: Use an App Password for Gmail.
bashPOSTFIX_RELAYHOST='[smtp.sendgrid.net]:587' POSTFIX_SMTP_USERNAME='apikey' POSTFIX_SMTP_PASSWORD='your-sendgrid-api-key'
bashPOSTFIX_RELAYHOST='[email-smtp.us-east-1.amazonaws.com]:587' POSTFIX_SMTP_USERNAME='your-smtp-username' POSTFIX_SMTP_PASSWORD='your-smtp-password'
bashPOSTFIX_RELAYHOST='[smtp.mailgun.org]:587' POSTFIX_SMTP_USERNAME='postmaster@your-domain.mailgun.org' POSTFIX_SMTP_PASSWORD='your-mailgun-smtp-password'
bash# View all logs (Apache + Postfix) docker logs wordpress # Follow logs in real-time docker logs -f wordpress # View last 100 lines docker logs --tail 100 wordpress # Filter for postfix logs only docker logs wordpress 2>&1 | grep postfix
PHP is configured to use Postfix for the mail() function.
bash# Enter the container docker exec -it wordpress bash # Send a test email via command line echo "Test message body" | mail -s "Test Subject" recipient@example.com # Test PHP mail function php -r "mail('recipient@example.com', 'Test Subject', 'Test message from PHP');" # Exit and view logs from outside the container exit docker logs -f wordpress # You'll see postfix logs showing the email being sent
WordPress will automatically use PHP's mail() function, which now routes through Postfix:
bashdocker logs -f wordpress | grep postfix
This project follows the same license as the official WordPress Docker image.


探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务