Sign inSign up

atws/docker-wordpress

By atws

•Updated 2 days ago

Forked from TrafeX/docker-wordpress on github

Image
0

50K+

atws/docker-wordpress repository overview

⁠WordPress Docker Container

Lightweight WordPress container with Nginx 1.24.0 & PHP-FPM 8.2.8 based on Alpine Linux 3.23

WordPress version currently installed: 7.1.0

  • Used in production for my own sites, making it stable, tested and up-to-date
  • PHP-FPM pool sized automatically from the container's memory limit, so the same image is safe from a 700Mi container up to 8Gi
  • Best to be used with Amazon Cloudfront as SSL terminator and CDN
  • Built on the lightweight Alpine Linux distribution
  • Can safely be updated without losing data
  • Fully configurable because wp-config.php uses the environment variables you can pass as a argument to the container

Docker Pulls License MIT Docker

⁠Usage

See docker-compose.yml⁠ how to use it in your own environment.

docker-compose up

Or

docker run -d -p 80:80 -v <volumename>:/var/www/html/wp-content \
-e "DB_HOST=db" \
-e "DB_NAME=wordpress" \
-e "DB_USER=wp" \
-e "DB_PASSWORD=secret" \
-e "TABLE_PREFIX=only_if_not_wp_" \
-e "FS_METHOD=direct" \
-e "DISABLE_AUTO_CHOWN=true" \
-e "DISABLE_AUTO_DB_UPDATE=true" \
atws/docker-wordpress:latest
⁠PHP-FPM tuning

pm.max_children is derived at startup from the container's own memory limit (the cgroup limit Kubernetes/Docker enforces), because a single static value cannot be right for both a 700Mi and an 8Gi container. The computed value is logged on every boot:

php-fpm sizing: pm=dynamic pm.max_children=7 (container memory limit 700MB - 192MB reserved, / 64MB per worker)

Roughly (container_limit_MB - reserved) / per_worker, clamped to 2..64, where per_worker defaults to half of PHP_MEMORY_LIMIT. Measured across live pods, a steady-state worker holds 25-45MB of unreclaimable memory against a 128M limit - opcache and the binaries are shared, and are counted in the reserve rather than per worker - so half the limit is a realistic budget with headroom.

Because the two are linked, raising PHP_MEMORY_LIMIT buys fewer workers rather than the same number of hungrier ones:

Container memoryPHP_MEMORY_LIMITpm.max_children
700Mi128M (default)7
700Mi256M3
1Gi128M (default)13
2Gi128M (default)29
4Gi512M15

If no container memory limit is set at all, the pool falls back to 16 workers and logs a warning - set resources.limits.memory so it can be sized properly.

Everything is overridable per container:

VariableDefaultEffect
PHP_FPM_MAX_CHILDRENderivedExact pm.max_children; skips the calculation, still clamped to 2..64
PHP_FPM_RESERVED_MB192Held back for nginx, opcache and the php-fpm master
PHP_FPM_MEM_PER_CHILD_MBhalf PHP_MEMORY_LIMITBudget per worker
PHP_FPM_PMdynamicProcess manager: dynamic or ondemand
PHP_FPM_MAX_REQUESTS500Requests a worker serves before it is recycled
PHP_MEMORY_LIMIT128MPHP memory_limit
PHP_MAX_EXECUTION_TIME30PHP max_execution_time in seconds

Prefer these over mounting a .user.ini into the docroot. .user.ini is PHP_INI_PERDIR, so it overrides both php.ini and PHP_MEMORY_LIMIT — a site that mounts one silently defeats the setting above and hides the real per-worker cost from the sizing, which is how sites end up OOM-killed.

If a site queues requests rather than crashing, raise the container's memory limit; the pool resizes itself on the next restart.

⁠WP-CLI

This image includes wp-cli⁠ which can be used like this:

docker exec <your container name> /usr/local/bin/wp --path=/var/www/html <your command>

⁠Inspired by

Tag summary

Content type

Image

Digest

sha256:92c8f9289…

Size

159.2 MB

Last updated

2 days ago

docker pull atws/docker-wordpress