You cannot muster up enough motivation to perform well at a job that you do not enjoy.

If you are living for vacations and weekends, your stuff is broken.

 

- Gary Vaynerchuck

Local WordPress Development with Docker

slides.com/tatemz/wcsac-2016

Tate Barber

medium.com/@tatemz

twitter.com/tatemz

Installing

https://www.docker.com/products/docker

Windows Caveats

  • Ensure virtualization is enabled
  • Share user directory
  • Reboot :-(

Mac Caveats

  • Brew is out of date
  • No need to reboot :-)

Easy Mode

version: "2"
services:
  database:
    image: mysql

  wordpress-site:
    image: wordpress

docker-compose.yml

  database:
    image: mariadb
    ports:
      - "8081:3306"
    environment:
      MYSQL_ROOT_PASSWORD: YourSSNGoesHere

database

  wordpress-site:
    image: wordpress
    volumes:
      - .:/var/www/html
    ports:
      - "8080:80"
    links:
      - database:mysql
    environment:
      WORDPRESS_DB_PASSWORD: YourSSNGoesHere

wordpress-site

version: "2"
services:
  database:
    image: mariadb
    ports:
      - "8081:3306"
    environment:
      MYSQL_ROOT_PASSWORD: IsThisSecure?

  wordpress-site:
    image: wordpress
    volumes:
      - .:/var/www/html
    ports:
      - "8080:80"
    links:
      - database:mysql
    environment:
      WORDPRESS_DB_PASSWORD: YourSSNGoesHere

docker-compose.yml

$ docker-compose up

http://localhost:8080

Details

Volumes

volumes:
  - "/local/path/:/container/path/"

Ports

ports:
  - "8080:80"

Linking

links:
  - "database:mysql"

The MYSQL CONTAINER

https://hub.docker.com/_/mysql/

  • Auto creates/configures database users
  • Auto starts mysql service

The WordPress Container

https://hub.docker.com/_/wordpress

  • Hardcodes the database hostname
  • Creates a database if it does not exist
  • Downloads WordPress if it doesn't exist
  • Auto configures the wp-config.php

configuration

https://github.com/docker-library/docs/tree/master/wordpress#how-to-use-this-image

Pros & Cons

Pros

  • Makes getting a local WordPress site up very easy
  • docker-compose files can be shared
  • No need for MAMP/XAMP, or tedious localhost configuration
  • Makes you kewl

Cons

  • Is not too polished on Windows
  • Not always viable for production
  • Multisite takes more configuration
  • Cannot handle WordPress in a subdirectory

toolaholic: (noun) - A person who, rather than spending time building something awesome, opts to build awesome tools in order to make their dev or build process more awesome in order to build something that will never be as awesome.

Fin

Local WordPress Development with Docker

By A. Tate Barber

Local WordPress Development with Docker

  • 578
Loading comments...

More from A. Tate Barber