Docker WordPress multisite with subdomains

docker wordpress -

The network setup for a WordPress multisite with subdomains can be scary. Nevertheless this post will demonstrate how easy it is to use docker-compose to create such a configuration. In addition it will run on your single local host, and you can use it for development, testing, or whatever you want. In a few simple steps you’ll have a docker WordPress multisite with subdomains!

Why use a docker WordPress multisite with subdomains?

Using subdomains for a web site is not everybody’s cup of tea. But if it is, then the network setup overhead is something which you don’t do very often. Letting developers work independently, testing and even just trying it out before publishing a new site needs to be easy. Therefore, I’m going to show you here just how simple it is to add such a setup using docker-compose and the EXPOSE SERVICE feature from a previous post.

It is that simple

  • First of all setup your local Linux as explained in EXPOSE SERVICE.
  • Then create a new directory for your docker-compose.yml:
ubuntu@docker:~/docker$ mkdir wordpress_multisite
ubuntu@docker:~/docker$ cd wordpress_multisite
  • Now put this in a new file named docker-compose.yml (based on this):
version: '3'

     image: mysql:5.7
       - db_data:/var/lib/mysql
     restart: always
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

     hostname: dockerwp
       com.theimpossiblecode.expose.domain: ""
       com.theimpossiblecode.expose.domainIsHost: "true"
       com.theimpossiblecode.expose.subdomainHosts: "support shop jobs"
       - db
     image: wordpress:latest
       - wp_data:/var/www/html
     restart: always
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress

This gives you a main site at, with these subdomains (for which you’ll add sites):

  • And last, all that is left is to start it up:
ubuntu@docker:~/docker/wordpress_multisite$ docker-compose up -d
Creating wordpressmultisite_db_1 ... 
Creating wordpressmultisite_db_1 ... done
Creating wordpressmultisite_wordpress_1 ... 
Creating wordpressmultisite_wordpress_1 ... done

That was all the networking setup!

To access your /var/www/html files simply use docker exec:

ubuntu@docker:~/docker/wordpress_multisite$ docker exec -it wordpressmultisite_wordpress_1 bash

To start your multisite setup, open your browser at, start the regular setup for the main site, and then follow these instructions to configure it as a multisite and add your subdomain sites.

Note – in the process you might get a “Warning! Wildcard DNS may not be configured correctly!”ignore this message and continue.

Hope you find this useful,

Sagi Zeevi

20 years writing code and still loving it!

You may also like...

Scroll Up