Wordpress designed to run as root for easy volume mounting. Ideal for plugin, theme and multi-site development.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Dockerfile Update to WP 4.2.2 May 7, 2015
README.md
config.yml
docker-entrypoint.sh
nginx-site.conf
supervisord.conf

README.md

Wordpress Docker image for Plugin, Theme and MultiSite Development

This image is intended for local development only. It runs Nginx and PHP-FPM as the root user so that Docker volumes mounted at /var/www/html can be written by the server processes.

This is totally awesome for local theme and plugin development, and the worst of all possible worlds if it happens to end up on a real server, so don't. Just don't. :simple_smile:

Usage

For more detail, see this initial blog post and the follow up where I enable multi-site.

I use this image with Docker Compose, thusly:

  1. Install Docker and Docker Compose. Instructions will vary depending on your system.

  2. Save the following in a repo somewhere as docker-compose.yml:

wordpress:
  image: gravityrail/wordpress
  volumes:
    - src:/var/www/html
  links:
    - db:mysql
  ports:
    - 8080:80

db:
  image: mariadb
  environment:
    MYSQL_ROOT_PASSWORD: example
  1. Create a directory call "src" in the same directory as docker-compose.yml

  2. Run docker-compose up. This will boot the WordPress and MariaDB docker images, install WordPress to your "src" directory, and run the server process.

  3. run open "http://$(boot2docker ip):8080", and install (for Linux, YMMV)

You can now install themes and plugins and mess with WordPress as much as you like!

Scripting the container with wp-cli

You can run the "wp" cli command as long as you include the "--allow-root" option, for example:

docker-compose run wordpress wp --allow-root plugin install hello-dolly

Nice, but noisy. On my own system (OS X, but this would work in Linux too), I created a wrapper for this using alias in my ~/.profile:

alias docker-wp='docker-compose run wordpress wp --allow-root'

Which turns the above command into:

docker-wp plugin install hello-dolly

Another example - let's create a new plugin!

docker-wp scaffold plugin my_super_plugin --plugin_name="My Super Plugin" 

AWESOMESAUCE.

Enable MultiSite

The magical, wp-cli way:

docker-wp core multisite-convert --title="My Blog Network"

One caveat of the configuration is that I use "folder" rather than "subdomain" MultiSite, for ease of use. I leave the necessary DNS shenanigans for local subdomain development as an exercise for the reader :simple_smile:

Credits

All credit must go to https://github.com/docker-library/wordpress, from which this code was shamelessly and inexpertly copied.