Public Repository

Last pushed: 2 years ago
Short Description
Wordpress designed to run as root for easy volume mounting. Ideal for plugin and theme development.
Full Description

This description copied from the github repository.

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.

Docker Pull Command
Owner
gravityrail

Comments (3)
lmartins
2 years ago

This is so useful for local development, as other images always cause issues with file permissions. This one haves an issue though. Any error on your PHP code will cause nginx to return a 404 error, leaving you no way o debug your code.
Hope this can be improved, as well added the option for xdebug

troyvega
2 years ago

Thanks a lot for elucidating this precious information in such effective and simplistic way. As such, I am new on WordPress and have recently stated my first blog on the subject of photography using Skylab v1.2.4 (Photography WordPress Theme). I downloaded it from. It looks incredibly awesome. I am so pleased to be a part of WordPress and will continue to be associated with it. Currently, I am seeking for new technologies about WordPress in order to strengthen my concepts and thankfully, your post helped me to learn one more essential thing.

mendalhocks
2 years ago

nice post, thanks dear