I am getting started with Docker and I'm still new to professional WordPress development practices. I would like to set up a Docker development environment (on my Mac) so that I can do custom WordPress theme development.

Assuming you have done this before and are already using Docker, how did you set this up? What does your Dockerfile and docker-compose.yml look like? I'm sure this has been done before. I wouldn't be surprised if there's already one-line command that can set this up for you.

Update: I've narrow this topic down to the following question:

How can I configure Docker for developing and deploying a custom theme?

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • I just had to delete two link only answers. As your question has 8 upvotes, would you mind narrowing it down to one question that is solvable? – kaiser Mar 23 '16 at 12:02
  • @kaiser "Professional WordPress development" is not very well documented, so many people (including myself) are trying to learn how to work with WordPress in a professional way to develop and deploy custom WordPress themes. Using Docker helps to create an environment that mirrors the production environment, but it's also new territory, so I'd like to know how people are incorporating Docker into their WordPress development workflow. – Andrew Mar 24 '16 at 5:07
  • Andrew, please take a look at this text to see what kind of questions we keep open on this site. As it stands, your question is very subjective, open ended and only attracts opinion based or link only answers. Please change that, else we will have to close the question. Thanks. – kaiser Mar 24 '16 at 7:17
  • @kaiser Okay, I've made my best attempt at changing this to be a more focused question. – Andrew Mar 24 '16 at 19:05

I'm going to post a partial answer to start the discussion in the hope of getting some helpful comments to fill in the blanks or alternative answers...

Step 1: Install and Set Up boot2docker

Docker only runs on Linux. So in order to use Docker on our Mac, we need to install boot2docker, which will run Docker in a Linux VM. You can install boot2docker using Homebrew:

brew install boot2docker

Once it has finished installing, set up and start boot2docker:

boot2docker init
boot2docker start

Next, we need to run a command to set up some environment variables so that docker-compose will know to find Docker inside our boot2docker VM.

eval "$(boot2docker shellinit)"

You may want to add the lines that export variables to your ~/.bash_profile so that you don't have to run the command every time you open a new terminal window.

Step 2: Install docker-compose

There is a Docker plugin called docker-compose (originally called fig) which makes it really easy to define the relationship between your Docker containers. You can also install it using Homebrew:

brew install docker-compose

Step 3: Create docker-compose.yml

There's an official WordPress Docker image in the Docker registry. It includes some information about manually starting up Docker with all of the command line flags necessary to make it all work. As far as I can tell, you can skip all of that because we will be using docker-compose. In the directory where you will be working on your WordPress theme, create a docker-compose.yml with the following contents:

  image: wordpress
    - db:mysql
    - 8080:80
    - .:/var/www/html/wp-content/themes/my-theme-name

  image: mariadb

The volumes configuration links our theme files in our current directory to a new theme directory inside the Docker container.

Step 4: Start the containers

Run docker-compose up and you will set up two Docker containers ("wordpress" and "db") running an installation of WordPress.

Step 5: Open the site in the browser

Our docker-compose.yml configuration specified that we are forwarding port 80 to port 8080. Also, boot2docker runs its VM on a specific IP address. Thus, in order to figure out the URL, we need to use the boot2docker ip command:

open http://$(boot2docker ip):8080


Now that I have the containers up and running, I have a few questions...

  1. Is there an automated way of setting up the boot2docker environment variables, other than copy and paste the exports listed in boot2docker shellinit?

  2. When I'm working on a Rails application, I like to use Pow so that I can access the app using a named .dev domain instead of working with specific ports/IPs. How can I configure my system (or Pow) so that I can access the host using http://mysite.dev?

  3. Are there any steps that I missed? Or are there any steps that should be added to the end?

My preferred solution for this is using Composer in combination with Docker. Docker handles the environment, Composer handles the dependencies, which includes themes, plugins, and any other packages I might need.

Here's my own local Docker setup:


And here's a branch that uses Composer to download the _s theme and place it in my themes directory:


protected by kaiser Mar 24 '16 at 7:18

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.