Step by step guide to a wordpress docker

This guide is a quick-and-dirty, copy-paste ready step by step guide to a docker based clone of a live wordpress site.

It is based on Gear11 tutorial and depends on Gear11 Docker available on Github. No fancy, this page is a copy of the github README edited for personal purpose, you may want to refer to original documentation for a detailed guide.

Create and setup a dedicated machine

$ docker-machine create --driver virtualbox wordpress
$ VBoxManage modifyvm "wordpress" --natpf1 "http,tcp,127.0.0.1,80,,80"
$ VBoxManage sharedfolder add "wordpress" --name "wp-install" --hostpath "/Users/fugaz/Share/wp-install/"

Start the machine

$ docker-machine start wordpress
$ eval $(docker-machine env wordpress)

Configure VM

$ docker-machine ssh wordpress
$ mkdir ~/wp-install
$ sudo mount -t vboxsf wp-install ~/wp-install

Build Dockerfile

$ git clone https://github.com/gear11/G11DockerWP
$ cd G11DockerWP
$ sudo docker build -t="g11-docker-wp" .

Create a Duplicator archive and download archive + install file to /Users/fugaz/Share/wp-install/
Launch the container and install wordpress with

$ docker run -i -p 80:80 -v /Users/fugaz/Share/wp-install/:/wp-install -t g11-docker-wp -u http://192.168.99.100 -s

WordPress will be available at 192.168.99.100.

Save a snapshot and restart it

$ docker commit <container id> g11-docker-wp/snap1
$ docker run -i -p 80:80 -v ~/wp-install:/wp-install -t g11-docker-wp/snap1

Future plans and improvements:

  • use regular wordpress and mysql containers
  • skip the Duplicator plugin
  • integrate into a jenkins job

Leave a Reply

Your email address will not be published. Required fields are marked *