Learn how to run WordPress with Docker. Read about our experiences and start off with an easy boilerplate.

Overview

Docker WordPress Logo

License Support us
Discourse users Discord

Hi! We're Dan and Jay. We're a two person team with a passion for open source products. We created Server Side Up to help share what we learn.

Find us at:

  • 📖 Blog - get the latest guides and free courses on all things web/mobile development.
  • 🙋 Community - get friendly help from our community members.
  • 🤵‍♂️ Get Professional Help - get guaranteed responses within next business day.
  • 💻 GitHub - check out our other open source projects
  • 📫 Newsletter - skip the algorithms and get quality content right to your inbox
  • 🐥 Twitter - you can also follow Dan and Jay
  • ❤️ Sponsor Us - please consider sponsoring us so we can create more helpful resources

Our Sponsors

All of our software is free an open to the world. None of this can be brought to you without the financial backing of our sponsors.

Sponsors

Running WordPress on Docker

Ready to take the dive and modernize WordPress with Docker?

Long story short, it can be definitely be worth it depending on your use case. From our experience, you can save yourself hours, or really over-engineer and dig yourself a hole.

👉 "The WordPress Way"

We're very grateful for WordPress, and it even runs our blog for Server Side Up. The only downside with WordPress is it has a lot of history with it. That means the core was written with in a mindset before all of the fancy and flashy methods that we have today.

The most important thing you need to remember is always try to do things "The WordPress Way".

The more you work with it, the less you are fighting the platform.

What do you mean by "fighting the platform"?

Introducing modern toolsets to WordPress may allow you to get WordPress up and running, but severely limit you to the rest of the community tools.

This could be things like (but not limited to):

  • Using NGINX as the web server
  • Deploying updates by packaging WordPress into a Docker Image
  • Using too new of a PHP version
  • Using Roots Bedrock to modernize your development flow

We've tried all of these above and we learned that most of the plugins that we relied on had issues with this.

So how does Server Side Up run WordPress?

We embrace these principals:

  1. Always do things "The WordPress Way"
  2. Keep plugin installation to a minimum
  3. Always use Apache as the webserver
  4. Only commit your own source code (not WordPress core or another plugin)

The structure

We run WordPress in production on Docker Swarm using:

  1. Traefik (handles SSL automatically with Let's Encrypt)
  2. Our PHP-Apache image (this is optimized for WordPress)
  3. MariaDB (the "non-Oracle" alternative to MySQL)

Deploying updates

We attempted to deploy WordPress with rolling updates (like we do with Laravel) by packaging WordPress into a Docker image use theRoots Bedrock framework, but we ran into a ton of issues with community plugins.

Our most stable solution (following "The WordPress Way") is to:

  1. Mount /var/www/html of the container to the host
  2. At the host container, run an SSH git pull from our CI system

Ugly, but it works 🤷‍♂️

Running WordPress Locally with this method

In this repository, you will find a basic boilerplate of what we use when we start a new WordPress project.

Clone this repo down

[email protected]:serversideup/docker-wordpress.git

Install WordPress

# Make sure you are in the project folder
cd docker-wordpress

# Download and extract WordPress
wget -c https://wordpress.org/latest.tar.gz -O - | tar -xz -C public/ --strip=1 wordpress/

Configure your hosts file

This example uses "wordpress.dev.test" for the URL, so we would add this to our hosts file:

127.0.0.1 wordpress.dev.test

Bring up your containers

We use Docker Overrides to separate our environments.

For now use this ugly command, but we are working on open sourcing a tool called Spin that will greatly shorten this:

docker compose -f docker-compose.yml -f docker-compose.dev.yml up

⚠️ Make sure you allow MariaDB to provision the user the first time. You'll see something like this in the logs:

docker-wordpress-mariadb-1  | [Note] [Entrypoint]: Creating database wordpress
docker-wordpress-mariadb-1  | [Note] [Entrypoint]: Creating user wordpress_database_user

Visit your WordPress site

Just go to https://wordpress.dev.test/ in your browser. You should see the WordPress install wizard.

The credentials are set in docker-compose.dev.yml. By default they are:

  • Database Name: wordpress
  • Database Username: wordpress_database_user
  • Database Password: wordpress_database_password
  • Database Host: wordpress_mariadb

Running WordPress in production

We use Docker Swarm for running WordPress in production (just because it is so much simpler than Kubernetes).I left our docker-compose.prod.yml file in there, but there are a number of things that we do in production that would take longer than writing this document 😅

If there is interest on how we do this, just let us know. Hit me up on Twitter and express your interest on learning more.

For this first commit, I just wanted to at least give you a perspective on how we run things.

As always, if you know of a better way, let us know!!

You might also like...
RedeemeRadio is the radio station of Alexander Schliker, our Redeemer and Super Hero (he actually flies).

RedeemeRadio - README Welcome to the RedeemeRadio project -- an open source project for allowing broadcasting the radio of Alexander Schliker, our Sup

Result of our code-along meetup writing PHP 8.1 code

PHP 8.1 Demo Code This code demonstrates various PHP 8.0 and 8.1 features in a realistic, functional (but incomplete) codebase. The code is part of so

Music website developed as a final group project for our Webpage Development class.

double-drummer Music listening website developed as final group project for our Webpage Development course. All parts that disclosed any information r

Show caffeine intake stats for our office coffee machine
Show caffeine intake stats for our office coffee machine

Coffee brewing statistics for the Spatie office Over at Spatie we drink a lot of coffee. How much coffee? We had no idea until we created this dashboa

Rocket Web Prime theme based on Magento Blank that includes our most common customizations.
Rocket Web Prime theme based on Magento Blank that includes our most common customizations.

RW Prime - Magento 2 boilerplate theme RW Prime theme is based on Magento Blank and includes our most common customizations that we make on the majori

 A complete solution for group projects in organizations that lets you track your work in any scenario. Working in a team is a cumbersome task, ease it using our project management system.
A complete solution for group projects in organizations that lets you track your work in any scenario. Working in a team is a cumbersome task, ease it using our project management system.

SE-Project-Group24 What is Evolo? Evolo is Dashboard based Project Management System. A complete solution for group projects in organizations that let

A repository for showcasing my knowledge of the PHP programming language, and continuing to learn the language.

Learning PHP (programming language) I know very little about PHP. This document will list all my knowledge of the PHP programming language. Basic synt

🏆 Learn You PHP! - An introduction to PHP's core features: i/o, http, arrays, exceptions and so on.
🏆 Learn You PHP! - An introduction to PHP's core features: i/o, http, arrays, exceptions and so on.

Learn You PHP! The very first PHP School workshop. A revolutionary new way to learn PHP Bring your imagination to life in an open learning eco-system

Wordpress Plugin Boilerplate but Powered with examples and a generator!
Wordpress Plugin Boilerplate but Powered with examples and a generator!

WordPress Plugin Boilerplate Powered WordPress Plugin Boilerplate Powered is a complete foundation for building your WordPress plugins following PSR-4

Owner
Server Side Up
Quality tutorials & resources. No BS.
Server Side Up
Hi everyone! This is our repository for our final project in college. We're sorry if so many bug or error. Thank You

About The Project Hi everyone! This is our repository for our final project in college. We're sorry if so many bug or error. Thank You About Laravel L

Lintang Bima Sakti 3 Dec 9, 2021
Run your WP site on github pages, php innovation award winner https://www.phpclasses.org/package/12091-PHP-Make-a-WordPress-site-run-on-GitHub-pages.html

Gitpress Run wordpress directly on github pages Gitpress won the innovation award for may 2021 Read more about this https://naveen17797.github.io/gitp

naveen 13 Nov 18, 2022
Foundation 3 Framework for Magento 1.7. Foundation styles and libraries. Magento Responsive theme. Off-canvas Left-Right sidebar columns for mobile.

Magento Foundation 3 Framework Zurb Foundation 3 framework for Magento 1.7. Magento Foundation 3 Version 1.3.0. Demo page: http://magendation.internet

Nando Boronat 62 Apr 1, 2022
Quick start Symfony 5 project via docker-compose

Quick Docker Symfony This repository will allow you to start a Symfony project very quickly with PostgreSQL 14, pgAdmin 4 and one of three php version

null 2 Aug 7, 2022
A back-off strategy interface for retrying operations.

EventSauce BackOff This library provides an interface for encapsulated back-off strategies. composer require eventsauce/backoff Leveraging the back-of

EventSauce 59 Dec 19, 2022
Turn redstone lamps on or off by touching them

TouchLight Turn redstone lamps on or off by touching them Usage Just place a redstone lamp and turn it on or off by touching or right clicking it View

Daniel Hex 4 Sep 24, 2021
A complete stack for running Symfony 5 into Docker containers using docker-compose tool and with Certbot for the HTTPS certificate.

?? Docker + PHP 7.4 + MySQL8.0 + Nginx + Certbot(HTTPS) + Symfony 5 Boilerplate ?? Edited from https://github.com/ger86/symfony-docker version -> http

null 6 Nov 9, 2022
Docker-magento2 - 🐳 Docker containers with all required Magento 2 dependencies installed available as FPM through Nginx and CLI

Magento 2 Docker A collection of Docker images for running Magento 2 through nginx and on the command line. Quick Start cp composer.env.sample compose

Meanbee 454 Dec 27, 2022
Docker-magento - Docker image for Magento 1.6 to 1.9

Docker image for Magento 1.x This repo creates a Docker image for Magento 1.x. Please note The primary goal of this repo is to create Docker images fo

Fu Cheng 144 Nov 18, 2022
🐋 This project aims to broaden knowledge of system administration by using Docker: virtualizing several Docker images, creating them in a new personal virtual machine.

?? This project aims to broaden knowledge of system administration by using Docker: virtualizing several Docker images, creating them in a new personal virtual machine.

Anton Kliek 1 Jan 26, 2022