Multisite WordPress installation using a Docker image

If you’ve ever thought about setting up a multisite WordPress installation via Docker I highly recommend you do so as it is an excellent project to revisit several topics.


  1. Load new Oracle 7.7 system via PXE and join to domain
  2. Install Docker & Docker Compose
  3. Acquire Docker Compose script from online video (Reference:
  4. Modify script to work in an SELinux enabled environment
  5. Modify script to work with multisite
  6. Modify script to allow a larger upload size
  7. Run Docker Compose
  8. Configure WordPress for multisite
  9. Setup DNS entries & modify sites to use full domain names

What is great about this Docker setup is by stopping and then restarting the Docker Compose, WordPress will automatically be updated if a new release has come out.  With a High Availability setup, you can restart one WordPress instance at a time, allowing for no downtime during upgrades.

Start with a clean installation. For this presentation I’m using Oracle Linux 7.7, which is based on Red Hat, similar to the way CentOS is though with its own repositories.
Configure host & setup user (or join domain). Logout & switch to user account.
My repositories were configured automatically via the PXE kickstart file. For those new to Oracle Linux instructions for setting up repositories can be found here:
(docker is provided by ol7_addons repo)
(python-pip is provided by ol7_developer_EPEL repo)
# install docker
sudo yum -y install docker

# add user who will be running docker to docker group
sudo usermod -aG docker travis

# enable docker to start up at boot & start
sudo systemctl enable docker
sudo systemctl start docker

# install pip which will be used to install docker-compose
sudo yum -y install python-pip

# install docker-compose
sudo pip install docker-compose
# create directory to store docker compose configuration & change to it
mkdir -p docker/wordpress
cd docker/wordpress

# create uploads.ini file which is used to configure a larger upload size
cat > uploads.ini
upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 400M
file_uploads = On
max_execution_time = 180

# create docker-compose.yaml file
# original version:
cat > docker-compose.yaml
version: '3'
   # Database
     image: mysql:5.7
       - db_data:/var/lib/mysql
     restart: always
       MYSQL_ROOT_PASSWORD: password
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: password
       - wpsite
   # WordPress
       - db
     image: wordpress:latest
       - '80:80'
     restart: always
     privileged: true
       - ./html:/var/www/html
       - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: password
       - wpsite

Notes on docker-compose.yaml:
1. MySQL is loaded via Container image. Data is stored in local volume.
2. MySQL & WordPress are able to interact via a local network wpsite.
3. With a Multisite configuration port 80 is required.
4. “Privileged” must be used as we are using an enforced SELinux environment.

# create directory to store wordpress files
mkdir html

# Start up WordPress via docker-compose
docker-compose up -d

# Configure firewall
firewall-cmd --permanent --add-port 80
firewall-cmd --reload

Next a configuration file must be modified:

Locate the string “That’s all, stop editing! …” and add the following lines after:

define(‘WP_ALLOW_MULTISITE’, ‘true’);

After logging into the WordPress site for the first time browse to:
Tools -> Network, choose subdomains or subfolders and follow directions.

Finally, you can use a domain instead of a subdomain or subfolder by first creating a site with a subdomain or subfolder then, after configuring the domain in DNS, go back to the site and modifying the URL with the domain. For example: –>

Posted in Infrastructure.

Leave a Reply