Vagrant vs Docker: Which is better for WordPress development?


For some time now Vagrant has been the go-to solution for creating development environments that can be configured independantly of your machine and shared with a team. There are many benefits to using virtual machines over installing software directly on your local machine (as MAMP does for example):

  • Software stacks are entirely independent from the machine you are working on.
  • Software stacks can be shared with other people and be reproduced automatically with ease.
  • Virtual machines can be started and stopped as required.
  • Hosting environments become ephemeral and can be thrown away when no longer useful.
  • It saves a lot of time.

Over the last couple of years, however, a new kid on the block has been gaining traction. While Docker also runs on a virtual machine it works in a fundanmentally different way. In this post we’re going to look at the difference between Vagrant and Docker and show you how to set up a WordPress development site in each.

Vagrant vs Docker – High Level Comparison

Vagrant utilises a much simpler architecture than Docker. It uses virtual machines to run environments independent of the host machine. This is done using what is called “virtualization” software such as VirtualBox or VMware. Each environment has its own virtual machine and is configured by use of a Vagrantfile. The Vagrantfile tells Vagrant how to set up the virtual machine and what scripts need to be run in order to provision the environment.

The downside to this approach is that each virtual machine includes not only your application and all of its libraries but the entire guest operating system as well, which may well be tens of GBs in size.

Docker, however, uses “containers” which include your application and all of its dependencies, but share the kernel (operating system) with other containers. Containers run as isolated processes on the host operating system but are not tied to any specific infrastructure (they can run on any computer).

What is the upshot of all of this?

  • Vagrant is easier to understand and is easier to get up and running but can be very resource intensive (in terms of RAM and space).
  • Docker’s architecture is harder to understand and can be harder to get up and running but is much faster, uses much less CPU and RAM and potentially uses much less space than Vagrant VM’s.

Setting up Vagrant

One of the great things about both the Vagrant and Docker ecosystems is that, due to the fact environments are easy to script and share, there are loads of great Vagrant “boxes” and Docker images already available to use.

In this case we are going to use a project called Varying Vagrant Vagrants (VVV) which is a popular vagrant configuration specifically designed for WordPress development. Before we begin, you will need both VirtualBox and Vagrant installed on your machine.

There are also several Vagrant plugins that VVV recommends you install:

  • vagrant-hostsupdater – Automatically updates your hosts file to access the provisioned VVV domains in your browser.
  • vagrant-triggers – Allows for various scripts to fire (such as database backups) when issuing commands such as vagrant halt and vagrant destroy.

Now that we have all the prerequisites installed let’s clone the VVV repo:

$ git clone git:// vagrant-local

Then we simply need to cd into the directory and run vagrant up:

$ cd vagrant-local && vagrant up

It will take Vagrant a while to download the required files, set up the virtual machine and provision it. (Note: if you’re using the “vagrant-hostsupdater” plugin you may be prompted for your password.) Once the provision script has finished you should be able to visit and see WordPress! I recommend you read the VVV Readme for more information on how to set up and use VVV WordPress sites.

Setting up Docker

To get started with Docker first you need to install the Docker Toolbox which provides you with not only the Docker Client, but also Docker Machine (which controls the Docker Engine, previously boot2docker) and Docker Compose (which allows you to specify a multiple container setup in a single file) as well as some other bits and pieces.

Once you have it installed, the first thing you need to do is set up a Docker Virtual Machine. Docker will use this virtual machine to run the Docker Engine which manages any containers that you want to run. To do this let’s create a Docker Machine using VirtualBox called “docker-vm”:

$ docker-machine create --driver virtualbox docker-vm

Once the machine has been created we can check the details of the machine by running:

$ docker-machine env docker-vm

It should output something similar to:

export DOCKER_HOST="tcp://"
export DOCKER_CERT_PATH="/Users/gilbitron/.docker/machine/machines/docker-vm"
export DOCKER_MACHINE_NAME="docker-vm"
# Run this command to configure your shell:
# eval "$(docker-machine env docker-vm)"

You’ll notice that these are actually commands that set environment variables for the Docker Client to communicate with the Docker Engine. So we do as we are told and run:

$ eval "$(docker-machine env docker-vm)"

Top tip: Every time you open a new session you will need to run this eval command as these settings don’t persist. So to save you this hassle you can add the eval command to your ~/.bashrc file so that it is run automatically every time you open a new session.

Now we are finally able to start creating Docker containers. One important thing I should point out here is that Docker encourages running only one process per container. This means that technically if we were running a LAMP stack, Apache, MySQL and PHP-FPM should all be run in their own containers. These, however, are only guidelines and in most cases it’s fine to group relevant processes together (for example Apache and PHP would normally run in one container, and MySQL in another container).

Thankfully there are official Docker images for both WordPress and MySQL that we are going to use. We will run WordPress (which includes Apache and PHP) in one container and we will run MySQL in a different container as the database.

To create a MySQL container run:

$ docker run --name wordpressdb -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=wordpress -d mysql:5.7

You can have a look at the docker run reference to see what each of these flags does in detail but here is a quick rundown:

  • We give our container a --name so we can link to it later (if we didn’t specify this a random name would be generated).
  • We specify two -e environment variables that will be used by the container. This is a common way of passing configuration information to a container.
  • We tell the container to run in detached mode.
  • Finally we specify the image:version we want to use. If the image doesn’t exist locally it will be downloaded.

Next let’s create a WordPress container:

 $ docker run --name wordpress -e WORDPRESS_DB_PASSWORD=password -v "$PWD/":/var/www/html --link wordpressdb:mysql -p 80:80 -d wordpress

There are two things we did here that we didn’t do for the MySQL container above:

  • We specified a -v volume to map our “Present Working Directory” to the /var/www/html folder inside the container (note that $PWD could be an absolute or relative path as well). This allows us to manipulate the WordPress files.
  • We --linked this container to our wordpressdb container and gave it an alias mysql. This allows the WordPress container to connect to the MySQL container.
  • We set up ports so that port 80 on our virtual machine points to port 80 in the Docker network (which will be this container).

We can check the status of our containers by running:

$ docker ps

Now you can simply visit the IP address of your Docker Machine (you can find the IP address by running docker-machine env docker-vm like we did above and looking at the DOCKER_HOST value) et voilà you should see a WordPress install screen. Now would be a good point to add a local domain to your hosts file so you don’t need to use the IP address all the time. You should also see the WordPress files in your $PWD as we set it up as a volume earlier.

Bonus: Use Docker Compose

Running commands like we did above can be quite cumbersome and prone to human error. Docker Compose can help us out as it allows us to specify a single file in which we can define our entire environment structure and run it with a single command (much like a Vagrantfile works).

Let’s create a docker-compose.yml file:

  image: wordpress
    - "80:80"
    - ./:/var/www/html
    - wordpressdb:mysql

  image: mysql:5.7
    - MYSQL_ROOT_PASSWORD=password
    - MYSQL_DATABASE=wordpress

You can see how we’ve just replicated the commands above into a yml file (using the compose file reference). Now all we need to do is run:

$ docker-compose up -d

So Which is Better?

As with all things of this nature there is no “right” and “wrong”, “better” or “worse”. It depends entirely on how you want to use it and what you feel comfortable with. I personally dabbled with setting up a Docker development environment recently but decided it was just too complex to get things working the way I wanted. I’m happy using Vagrant for the time being as it’s simple and just works, but I’ll be keeping an eye on Docker as the project matures and things will no doubt become easier.

What do you use for your development environment? Do you prefer Vagrant, Docker or something else?

About the Author

Gilbert Pellegrom

Gilbert loves to build software. From jQuery scripts to WordPress plugins to full blown SaaS apps, Gilbert has been creating elegant software his whole career. Probably most famous for creating the Nivo Slider.

  • Very interesting. I could see Docker becoming a go-to in the future. Thanks for the post!

  • I’ve finally got my Vagrant environment working smoothly on a consistent basis. The idea of using less resources is appealing, but if @gilbitron finds Docker overly complex, I most certainly will too.

    • Haha. To be fair Docker is targeted more at production deployments than development environments, which might explain the added complexity. Hopefully things will be easier in the future.

    • JamesDiGioia

      Also note that Docker doesn’t run natively on OS X (or Windows I presume), so you will need to start up a VM anyway to use it for Docker. Presumably, this VM will be smaller & lighter than the one you’d use normally, but it’s still there.

      • Vincent

        Now it runs natively on OS X and soon will be available in the same way on Windows

    • Lawrence Eagles

      It is as local development environment based on docker. It has everything automated for you like vvv, but comes with all the advantage of using docker.

  • boydbme

    One issue I have come across every time I check out Docker is that there does not seem to be a tool similar to the vagrant hosts tool that will make my project available to me at or similar. Last time I investigated a few months ago, I was finding guides about setting up your own DNS server within a docker container to manage the addresses for all your projects. O.o

    I’m very interested to see how Docker matures, and as time goes on I’m sure additional layers of abstraction will make it easier for us non-sysadmin types to jump it!

  • Thanks for another quality post Gilbert. However, I need to get up on a soap box…

    I really dislike all the negativity toward MAMP. I’m all for virtual machines and what not, but not every developer needs to run Vagrant or Docker to develop. It’s also becoming a trend to sort of “poo poo” on devs who still use MAMP or DesktopServer.

    “Virtual machines can be started and stopped as required.”

    I can also start and stop MAMP as required.

    “Hosting environments become ephemeral and can be thrown away when no longer useful.”

    With MAMP Pro, I can also remove virtual hosts when no longer useful.

    “It saves a lot of time.”

    This is subjective and your mileage may vary. I’ve run Vagrant (and did for about 4 months) before it completely stopped working because of some odd one-off network bug. I spent an entire day trying to fix it. I reached out to colleagues (who are much smarter than me) who also couldn’t fix my Vagrant instance. Finally, after 1.5 days (that’s 11 billable hours) I switched back to MAMP Pro.

    It should also be noted, that depending on your machine, Vagrant can actually be SLOWER than MAMP. As a front-end developer, waiting on the page to refresh (after compiling Sass) seconds do matter. Seconds add up when you do this all day! When I was running Vagrant it was easily 3-4 seconds slower on subsequent page reloads than MAMP Pro.

    Like you said, it depends on what you feel comfortable using. I just wish articles didn’t start off comparing these to MAMP and other built-in software which has been around forever and still meeting the needs of many developers out there.

    • Dovy Paukstys

      Agreed. I’m a system admin, data system architect, etc and I still use Mamp Pro locally because it’s tons faster and painless. I have some 130 virtual environments on my computer using mamp. Click and go.

      That being said, if I need a specific environment I want to test for say build boxes, vagrant/docker is the way to go. Just not for everyday dev for me.

      • Burhan Ibrahimi

        if you are in Mac, I’dont know why you need to have MAMP 😉

    • Hi Greg. To be clear I wasn’t trying to put MAMP down (I completely agree its more than enough for some developers and I still use it every day) I was just comparing it to Vagrant/Docker as they both make use of virtual machines.

      > With MAMP Pro, I can also remove virtual hosts when no longer useful.

      This isn’t quite the same as completely ephemeral environments. You can get rid of the virtual host yes, but the underlying software (PHP, Apache, MySQL etc.) are still installed on your host machine.

      • I know you weren’t. My “soapboxiness”, is just a lot of pent up frustration over all the finger pointing because I still use MAMP. 🙂

        • Not to worry Greg. Tools don’t solve problems, people do.

          Sure, sometimes the means can matter. But at the end of the day no one cares how the product was built, just that it works. 11 hours is a massive amount of time suck lost, that could have been used to actually improve something important.

          The hare might be sexy but it was the tortoise that won the race, eh 🙂 How quickly we forget.

    • I have used MAMP Pro religiously from its earliest incarnations and believe its an invaluable product! However I have moved over to Vagrant primarily as I can match the server environment technology that my live site would run on. I have in the past run into problems where i am debugging like a hell a project that works fine locally but as soon as it goes live it drops like a bombshell to find out its server configurations that cause it.

      This way with Vagrant I can match the server environments and I have not had one issue yet on publishing to live. Primarily I host with Media Temple and WPEngine and with the ability to git push to WPEngine staging areas, my developer time has improved dramatically.

      I haven’t tried Docker yet but it sounds interesting..

      the only issue i have is syncing files between different computers ie laptop and iMac when working remotely but Vagrant with Dropbox on Github seems to solve that issue storing your working files in the Cloud and interesting concept!

    • Matt

      Agree with Greg here. Different tools have different purposes and different qualities. In some situations one is better, in others a different one.

      In fact, I use both a tool like MAMP (AMPPS) and a virtual machine environment at the same time! For the 50-60 smallish wordpress projects of clients and other small projects, I have them all running inside MAMP. Creating a new project is as easy as clicking one button and filling in a name for the new local website. When a client calls with a question or problem about their website, I have a copy of their website running locally already and I can quickly test or change something. It would be impossible and cumbersome to have 60 sites running in VMs.

      For bigger or more specific projects, I can create a VM environment with specific configurations. It’s a bit more work to set up then with MAMP, but comes with the advantages of configuring the exact environment, sharing config with other devs, etc etc.

      Great article by the way Gilbert, thanks.

    • Ylletroja

      Agree. With tools such as MAMP (or the age old WAMP) one can have a dev-environment up and running in the time it takes to do a 3-minute install.

      The installation and running of your first thing is infinitely simpler then both Vagrant and Docker that both are plagued by problems and where one very easily can get stuck with debugging the application itself instead of working on ones code(s).

      • Michael Thomas

        That’s the situation I’m in, I managed to get VirtualBox working with VVV, but then ran into issues (apparently VirtualBox and Win 10 don’t like each other very much) My reason for using VirtualBox was to circumvent the lower case table names defualt set to 1 on windows and 0 on Linux. Now I’m back on WAMP how do I deal with the table names issue?

      • Michael Thomas

        I’m looking into changing the ‘lower case table name’ variable to 0 in mySQL settings – thanks

  • Chris Frazier

    Docker requires a Linux host to run on, so if you’re running on Windows or OSX, you still will need to run a virtual machine, making the comment that it “uses much less CPU and RAM and potentially uses much less space than Vagrant VM’s” not 100% accurate. For WordPress environments, Vagrant is much easier to get up and running with, especially if you use one of the publicly available boxes.

    That said, if you’re deploying some other type of web app (ex. NodeJS), Docker is absolutely brilliant for managing upgrades and changes in dependencies across different projects.

    • You’re 100% correct which is why you need to use Docker Machine to set up a VM (as described in the article). In my experience I’ve found the Docker Machine VM to be much more lightweight and faster than a Vagrant VM, but it does depend on how you use them.

  • David Blank-Edelman

    Hi Gilbert- Not sure if you noticed, but you can actually use Vagrant with Docker too (as a provider, just like VirtualBox, VMware, AWS, etc). Doc on this here:

    The benefit would be the ability to use them same set of commands to spin up things independent of how/where you want to run the VMs/containers.

    • Thanks for the heads up David. That looks like a helpful resource.

  • Joe Guilmette

    I use Vagrant (VVV) every day, and every once in a while I wonder when the time will come to switch to a different local dev platform. Thanks for the run down! My takeaway is that Docker is neat, but Vagrant is still easier for local dev.

    • Jon

      I love VVV and still use it daily, but I’m now starting new projects on HGV.

      I’m waiting for something that makes Docker as easy those do. Wocker comes close, but I’m not quite ready to try to put that in my real workflow yet.

      • Joe Guilmette

        Oh cool, this is the first I’ve heard of HGV. What do you like about it over VVV?

  • pbearne

    I would love to use docker but as windows user problems Docker Compose have stopped me for now. so like you I am “keeping an eye” on it and still using Vagrant for now
    I also need to see remote debug working.

  • Jon

    Once you’ve setup WordPress with Docker once manually so you know what’s involved, check out Wocker

    Automates the process considerably. I need to understand it a bit better before ditching Vagrant for Docker, but I think that’s the direction I’m headed soon.

    • Thanks Jon. Wocker looks really helpful.

    • tnorthcutt

      I’ve looked at Wocker before, looks like a good option. With the non-native OS X issue of having to still run Vagrant, does Docker/Wocker actually save much in terms of resources? My poor 2012 Macbook Air could use a break! I’d love to see a writeup from you @jb510:disqus if you make the switch.

      • Jon

        It’s seems lighter on resources to me. The paradox is Vagrant lets you setup individual local servers for every site, but most people don’t like doing that because who wants 25 VMs living locally.

        Wocker has the promise to have 1 VM, but 25 unique server environments. It’s not there yet, but that where I think it’s going.

        I’d totally write it up if I switched and got things running reasonable smooth.

  • Per Søderlind

    I use VVV, togehter with vv (, to build local WordPress dev sites. Using vv I can do: vv create –domain –name sites –prefix ms_ –multisite subdir

    I use docker for single applications like gearman and codeclimate.

    Btw, you can also use Parallels , run `vagrant plugin install vagrant-parallels` to install the provider

    • I’ve never used vv but it sounds like its similar to the WP-CLI but for VVV. Thanks for the info Per.

  • One issue I’ve run into using VMs is that I have to have several of them in order to match different environments. I fantasize about being able to develop under both Ubuntu and CentOS, Apache and NGINX, different versions of PHP, etc., simultaneously. I wonder if each of those could be separate containers running simultaneously within Docker and, if so, how to specify which OS to use at any given moment, which web server, etc.? (Note to self: Investigate this!)

    Currently I mostly use VVV and vv. I have modified both the Vagrantfile and the provisioning script to create different VMs to match the operating system, web server, PHP version, etc. as desired. I have four main VMs I use. These tend to be resource intensive so I tend to run “vagrant suspend” or “vagrant halt” before spinning up one of the others. Would be nice if Docker could provide a solution to this.

    • Hi Robert. It definitely sounds like Docker containers might be able to help you solve your problem of Vagrant VMs eating up all of your resources. Maybe you could setup multiple containers for each environment and then use something like to give each one a different hostname so you can access them all simultaneously. Something to investigate.

      • Thanks. I was thinking the same thing when you referenced that resource in an earlier reply. I will definitely have to investigate and do some experimenting.

  • Andrew Cato

    Local WordPress development while using Vagrant + VVV together is the only way to go, in my opinion (at least on Mac OS).

    It takes less than a dozen terminal commands (plus you have the ability to clone in essential plugins from a git repo during site creation) to get a site up and running in VVV. I don’t understand why you would use anything else (Docker, MAMP, etc.).

  • This looks interesting.

    I’ve also been experimenting with LXC/LXD for local WordPress development and have got some great results. Blog post here:

    It only really makes sense if you use Linux on your development machine.

    I’m close to getting all of this working with Vagrant.

    • Interesting, I didn’t know about LXC/LXD. Thanks for sharing.

    • nickwalt

      Yeah, I’m really interested in using LXC/LXD containers for all parts of the stack – especially with systemd. I just began learning about systemd just in the last week and, I think for many, getting to know systemd from the ground up will be a very interesting journey.

      Check out this excellent post from one of the developers of systemd, where he addresses a whole lot of FUD:

      The post gives good insight into what systemd is and where it is headed. Here is another link to the start of his “systemd for administrators” series of posts:

      He writes very clearly, so I find it a great read.

      There is a lot of great work being done with containers. RancherOS is a new entrant that is based entirely on Docker and even uses a special Docker init system – no systemd! The OS has two groups of containers: system containers and user containers. What will these guys come up with next?!

  • I work on a Windows machine and I was using Vagrant with Hyper-V, very well. There was just some small issues with permissions after a while and I found a much easier solution.
    Windows 8.1 and Windows 10 both come with Hyper-V installed (business editions, you shouldn’t use any other version) so no need for VMware of Virtual Box.

    I have taken to building small VM’s of Ubuntu and install RTcamps EasyEngine. Supper simple to spin up a new instance of WP or vanilla HTML or anything really. great for debugging and testing and the connecting of SFTP with PHPstorm makes everything sync so easily.

    They are supper small, 1 core, 1GB ram and expanding 20GB storage. WIN 10 has storage spaces so you use some old HDD or I use a 250 GB SSD and these things will complete a restart in less than 5 secs. Less than 15 min to build from scratch.

    So simple, easy to move around and update. If you use windows, make sure you Windows PRO 8, 8.1 or Win 10 and give it a go.

  • We switched to docker a while back, and after a few weeks of pain we now have the gain. (so the speak), It enables a dev environment that mimics live perfectly, as you are running the exact env whether on the frontends Mac or the backends Ubuntu. Using AWS EB service we can deploy our dockers with a single line of code.

    • Would you say the “gain” was worth the “pain”?

      • I think the gain was more to do with avoiding the age old WOMM (‘works on my machine’ issues) and other system setup issues that you patch on dev or live environments and then forget.

        And the pain was more about understanding dockers limitations with networking between dependent services as well as persistent storage.

        Its all come a long way in the last 6+ months, so I think it’s here to stay and grow.

    • Lawrence Eagles

      Hello Jack McNico if on you guys had used you would had the goodness of using docker wit hall the pain abstracted for you.

      wocker is a local development tool like vvv but is is based off of docker.

      it takes 3 seconds to create a container and the whole wordpress installation is automated. It is light weight not as heavy as vvv and thus GB wise it is better.

      • Usama Ahmed

        That is not docker, that is docker running inside vagrant virtual machine.

  • Jani Tiainen

    I’ve used both Vagrants and Docker for development. Vagrant is “easier”, you provision box and that’s pretty much it. You have full featured OS running in vagrant box and can do whatever you need there. Docker OTOH, uses Linux containers, so first you need Linux kernel (there is similar container technology coming to Windows Server 2016, but of course, it runs Windows processes).

    Docker is harder to understand since specially it’s concepts are more abstract. You need to have image(s) that are used to create running containers. Container itself runs isolated environment, sharing for example directories for development isn’t such a simple – one problem is that containers don’t share same users as a host. Also all processes within container does use paths that are relative to container filesystem which can be brain stressing sometimes.

    Personally I use Docker two ways – it’s really neat build system, like if you want to build special versions of software you can install everything in container, build and package and then just export built package from container. No need to install spurious software to local machine. Also since all programs runs as local isolated processes it’s really resource conservative. It uses just as much memory, cpu and diskspace it needs – and you can even control resource usage to keep them in line. Second usage is to run certain server software (in my case Mapserver for example) in container. It’s much easier to run different versions of servers and test that things just work.

    I’m also having experimenting to use containers to execute arbitrary user code (currently Python) in isolated environment. At it seems to be very interesting option. One already done implementation is dockersh ( It allows to run arbitrary safe, isolated shell in a browser. And it’s really resource conservative – try to run few hundred vagrants same way… 🙂

  • handrus

    Comparing Vagrant vs Docker isn’t fair. First of all you can use Vagrant to setup and run a docker machine. So whenever you compared ram usage etc, you where actually talking about Virtualbox vs Docker.

    One of the best things about using Vagrant is that you’re able to switch the provider based on the host machine. So if you’re running linux it can run a docker machine, if you’re on Windows on MacOS it could start a Virtualbox, or better yet, you can check which provider is available and use it.
    In the end of this page you’ll see how to do this latest trick (if docker is available run it, else if vmware is available use it and in the last case just use virtualbox)

  • In windows use Vagrant, but in linux docker is more fast

  • nickwalt

    Great article. However, I don’t think Docker and Vagrant are an either/or proposition:

    Vagrant, if I understand correctly, is a virtual machine provisioning tool and as such, orchestrates VMs at the hardware abstraction level (hypervisor).

    Docker is a container provisioning tool and orchestrates at the OS abstraction level (linux containers).

    Orchestrate your VMs with Vagrant, and orchestrate your Containers with Docker. Maybe use Chef or Puppet to fill your Docker containers with apps.

  • Very interesting write-up. I’ve been using Vagrant and VVV for a couple of years now (also with vv, as Per pointed out) and I’ve heard Docker come up quite a bit lately, but frankly I had no idea what it was. This introduction has been really helpful. I too have noticed my machine groaning under the weight of Vagrant sometimes, so the idea of something a little less resource intensive is intriguing, but given the complexity of Docker and the idea that “if it ain’t broke, don’t fix it”, I think I’ll be sticking with Vagrant (for now).

    • nickwalt

      Hi Dave,

      Docker doesn’t behave like a VM, so that might cause confusion to hypervisor guys. The concept is more like a lightweight application sandbox that can only contain a single app/process (App Container). The underlying technology of Docker is more like LXC than KVM (however, LXC can contain multiple apps/processes).

      The container technology most like VM technology is called LXD (OS Container). LXD builds on top of LXC by adding an identical experience to a true VM, except that an LXD guest OS must have the same Kernel-type as the host. So an LXD host can only support other Linux Kernels. See this excellent video of LXD at the OpenStack Summit: [LXD vs KVM].

      Vagrant doesn’t have an official LXC or LXD Provider right now (which is odd, considering that LXD will be a major technology on Ubuntu Server 16.04 LTS). There are a few Vagrant custom Providers for LXC that make the provisioning of Containers identical to that of VMs in the Vagrant workflow, which might also suit your requirements. This might be a good place to start: [this references the above lxc Provider]

      A couple of other references: [Scott references the above link]

      For those that don’t like abstractions that obscure too much in their infrastructure/dev tools (are focused on the nuts and bolts) LXC might be a better solution than Docker. Docker is being embraced by developers (primarily) because it wraps Linux Containers in a way that better suites their thinking and workflow. Docker made Containers easy for devs to consume at a high level so that they could get on with their work.

  • Reinaldo Mendes

    I think that Vagrant x Docker its a false dicotomy.

    You can use Vagrant with docker provider.

  • Joe Burdick

    So if we were making a docker container per project we would replace wordpressdb with the name of the project, be correct?

  • vincent

    hi Gilbert,
    sorry for saying so, but your article doesn’t bring anything to the discussion V. vs D.
    Thanks for the detailed example, but please consider renaming your post.

    • While @reinaldo_mendes:disqus’ comment below might be true, insomuch as “Vagrant x Docker its a false dicotomy,” I think plenty of people facing the same dilemma as @gilbertpellegrom:disqus would conduct exactly such a search, and upon landing here, find more than enough information to make a more informed decision from which to proceed.

      So, while the article might not have fully addressed your very specific needs with regards to “V vs D” (which, in another lexicon, is quite a different discussion, I might add with a smile), it certainly did mine, and pointed me in precisely the direction I needed to go. Cheers, Gilbert.

  • Jon Insley

    Have anyone used this? Docker4Wordpress

  • I’ve been developing on WordPress only sporadically, with maybe only a couple months of cumulative work. I tried using Docker, but it’s so “opaque”, and you really need to understand each container, to hook them up into a system. It’s taking me a while to get into it.

    Working in a VM feels a lot more like my local machine, except less cluttered, and with a platform that matches the deployment environment pretty closely. I really like being “inside” the machine’s shell when I’m going through the code-test-debug cycle. I like being able to experiment, copy files around, delete stuff, and be “messy”. Then when it’s working, deploy it into a fresh environment, and clean up the original workspace.

    The main thing I did to help this along was build a little virtual LAN with proxy servers to cache packages, so bringing up a new environment takes only a few minutes.

  • Lawrence Eagles

    This is a great article as someone who has tried both vagrant and docker in different forms, namely vvv(varying vagrants vagrant) & wocker ( I would say I must certainly sticking with wocker(the docker based local development tool).

    My reason for this is that:
    a. it uses a lot less resources and that includes GBytes also.
    b. it is light weight
    c. funny enough here the reverse is the case. wocker is much easier to setup than vvv and it takes much less time. vvv can take nearly forever if your internet is slow. (you should go for a long walk while installing it for the first time:-) ).
    d. All the issues that follows vvv. My experience of using vvv has been happy and cry, bitter sweeet. While one moment I’m enjoying all the goodness the moment you reboot your system to work, you may hit a blank white screen or it would fail to SSH or problem with virtual box or many other issues that got me crawling the web and github especially for solution.

    wocker is very promising only downside is the community may not be as large when compared.
    But all the same it is a great tool, one that I would be using for a longtime.

  • Arthur Vinogradov

    Man, I’ve tried to understand what is docker and all it’s components and your simple explanation rocked my world. Thanks a bunch.

  • Patrick Man

    Running the question by the Drupal community the overwhelming preference seems to be Docker.

  • Bronius Motekaitis

    Still a great tutorial even a couple years later 🙂 You might consider adding “-P” or “-p hostPort:containerPort” (from to let your fans easily connect via some MySQL GUI like Workbench or Sequel Pro to the WordPress DB container they just set up.

    Side note: If you’re updating stuff, I think “link” is considered less desirable now:
    > Publishing ports and linking to other containers only works with the default (bridge). The linking feature is a legacy feature. You should always prefer using Docker network drivers over linking.
    but that’s just something I stumbled across while looking for my Ports tip above.