Skip to content

domsekotill/docker-wordpress

Repository files navigation

Wordpress for Docker

gitlab-ico github-ico licence-mpl20 pipeline-status

Docker images for Wordpress.

The primary aim is to be secure and easy to deploy. Unlike other Wordpress images the statefulness is reduced to the bare minimum; aside from the required database only the uploaded media directory needs to be persistent, and even that can be avoided with a media cloud storage plugin1.

Two images are produced from the Dockerfile:

  • The primary runs a PHP server with a FastCGI (port 9000) interface (PHP-FPM), with Wordpress installed.

  • The second image runs Nginx with an HTTP (port 80) interface, which serves all the static files and proxies non-static requests to the PHP-FPM server.

Usage

Typical usage requires both images be run in containers on the same host, sharing a volatile (non-persistent) volume containing the static files, mounted at /app/static. This volume is populated by the PHP-FPM container during its startup.

The containers share another persistent volume for user-uploaded media files (if no media cloud storage plugin is used) mounted at /app/media.

The nginx container is not intended to be publicly accessible (it only listens on port 80). Some form of HTTPS termination is required at a minimum.

See the configuration document for an explanation of the configuration files and the available options.

See the Kubernetes example document to see an example deployment of pods running these services.

Build

Note: Building manually requires Docker 18.09 or later with the Buildkit feature enabled.

Note: (Dec 2020) Currently WP-CLI does not support PHP-8. Likely various plugins and themes also do not work with PHP-8. Therefore until wider support is available, supply a PHP-7 version with a build argument.

To build the PHP-FPM image run:

DOCKER_BUILDKIT=1 docker build -t wordpress:tag --build-arg php_version=7.4.13 .

To build the Nginx companion image, run:

DOCKER_BUILDKIT=1 docker build -t wordpress-nginx:tag --target=nginx .

Footnotes

  1. In a future release Simple Storage Service (S3) services may be supported out-of-the-box.