Wocker: Create a Docker-Based WordPress Development Environment in 3 Seconds

by on March 6, 2015

docker-wordpress

If you haven’t caught on to the Docker craze, it might be time to see what it’s all about. Fans of the open source container technology appreciate that it’s lightweight, super fast to boot up, and easy to share containers through the Docker Hub.

Docker standardizes an app platform and its dependencies so you can hand the box over to another party without worrying about conflicting dependencies or differences between machines. While virtual machines can be rather weighty with an application plus an entire guest operating system, Docker is much lighter, containing just the application and its dependencies.

Introducing Wocker

Vagrant 1.6.0, released last May, introduced support for Docker-based development environments, enabling Vagrant to manage them within Docker-powered Linux containers, instead of virtual machines.

WordPress developers who want to incorporate Docker into their workflow now have a new tool at their disposal. Wocker is a Docker-based rapid development environment of WordPress.

If you already have Vagrant, VirtualBox, and the vagrant-hostsupdater plugin installed, then getting started with Wocker takes next to no time. Simply clone the Wocker repository:

$ git clone https://github.com/wckr/wocker.git && cd wocker

Then run vagrant up. You can now navigate to your Wocker development site at: http://wocker.dev/. Here you’ll find the latest version of WordPress installed with the default theme active.

wocker

Running a new Wocker container takes just three seconds:

core@wocker ~ $ wocker run --name wp

The tasks of creating a new container, restarting a stopped container, or shutting down, can all be done in a matter of seconds with Wocker commands.

Kite Koga on Creating Wocker

Japanese WordPress developer Kite Koga created Wocker to speed up his own development. Koga is also the organizer of the upcoming WordCamp Kansai 2015.

“I used to use MAMP and VCCW for developing on WordPress,” Koga said. “MAMP is simple and easy but I have to download or copy WordPress core and create a database every time. VCCW is a great tool, and I still use it now and then. It has a lot of options and functions but takes awhile to provision.”

Koga also experimented with using VVV before creating Wocker. “Maybe VVV is good for developing WordPress core, but I feel it’s not fit for developing on WordPress. It takes too long to provision every time,” he said.

“Ultimately, I found that Docker was a good choice for me,” Koga said. “Once I have a Docker image, it takes only three seconds for every new WordPress container. However, Docker is a little tricky, and the command line is complex. Therefore, I made the Wocker command line to run containers and sync files with local more easily.”

Wocker is intentionally simple and limited to just a handful of options, as Koga’s primary objective was to make it super fast to create a new WordPress development environment. One drawback is that you cannot run two or more containers at the same time, but it takes just seconds to switch between containers.

Koga summarized the main reasons that he opted to use Vagrant to manage Docker deployments:

  1. I could write some provision scripts in the Vagrantfile, so users only have to do `$ vagrant up`
  2. It was easier to map hostnames to IP addresses.
  3. Vagrant with CoreOS was simpler to manage Docker images and containers than boot2docker.
  4. To sync files between local machine, virtual machine, and the Docker container was tricky, so I made Wocker commands to make it easier.

If you want to test out Wocker and find that it’s not for you, it’s easy and fast to uninstall. Simply run $ vagrant destroy to remove the Wocker folder, and your local machine will always be clean.

I tested Wocker and found that it was insanely fast to create new containers (as well as restart existing ones), a task for which I would require an extra utility (such as Variable VVV) to perform with VVV. If you find VVV to be too slow and want to check out an alternative, Wocker provides a faster way to set up simple development environments.

Source: WP Tavern

Wocker: Create a Docker-Based WordPress Development Environment in 3 Seconds

Related Posts

Take a look at these posts