TRAFEX TRAFEX Consultancy Consultancy
WordPress Docker image

WordPress Docker image

August 16, 2016

I’m moving all my sites and applications to Docker containers. The main reason is that it makes maintenance easier when everything an application needs is included in a single container. I can run everything on one server or split it up over multiple servers when I need more resources or high availability.


To containerize WordPress, I couldn’t find a container on that fit my needs. So I had to build my own with the following requirements in mind:


If you have a look at the Dockerfile, you’ll see the following things happening:

  1. It installs all the required packages and PHP extensions for WordPress
  2. It copies the Nginx & PHP-FPM configuration into the container
  3. It copies the supervisord configuration which makes sure both Nginx and PHP-FPM are started when you run the container
  4. It creates the volume for wp-content. That folder has all the files you want to persist.
  5. It downloads and extracts the WordPress archive to /usr/src/wordpress
  6. It copies the wp-config.php into the container which relies on environment variables to configure WordPress
  7. It copies the wp-secrets.php into the container which will hold the secrets and salts
  8. It copies into the container for bootstrapping WordPress for the first time
  9. It starts supervisord which will start Nginx & PHP-FPM

Entrypoint does only two things, and only when you start the container for the first time.

  1. When the wp-content volume is empty, it copies the wp-content folder from the WordPress install to make sure you’ve got the default theme and plugins.
  2. When the wp-content volume is empty, it generates the secrets & salts in wp-secrets.php with the API WordPress provides.

Use it yourself

The image is available on Docker Hub. Thanks to Alpine Linux, it’s only +/- 50MB.

Docker Pulls

I’ve also included a docker-compose.yml to have a working WordPress website with one simple command: docker-compose up

If you have any questions or feedback, just create an issue on GitHub

GitHub Repo stars

Go back

Related content


PHP Nginx Docker image

Example PHP-FPM 8.0 & Nginx 1.20 setup for Docker, built on Alpine Linux.

Read More


Caching WordPress with Nginx

I’m running a WordPress website on a small VPS with the help of Nginx and PHP-FPM. But I noticed the site was not that fast as I wanted it to be. This is mainly caused by the little resources this VPS has. So every request needs to be as efficient as possible. To make that possible, I want to cache the requests with Nginx to minimize the requests that needs to be handled by PHP-FPM.

Read More