Rss

Archives for : June2016

Docker & PHP – on Windows

Deciding I needed to learn more about docker and finally start using it, I decided to give it a little try.

Docker on Windows… not so¬†quick

A recent application I downloaded wanted to install an entire WAMP (Windows-Apache-MySQL-PHP) stack on my computer. There’s no way I’m having all of that installed and running.

I knew this was possible in docker, so I thought I’d start my foray into docker land with creating my own WAMP stack. It turned out to be more a VDLNMP stack; as you’ll see.

After much searching amid a very log signal-to-noise ratio, I finally found an excellent tutorial at a place called osteel’s blog.

I was merrily following along until the instruction came to mount the local dev folder into the docker container. Now I’m running on Windows, so I’m using docker machine, and after some searching discovered that docker machine just doesn’t work like that.

I’d have to somehow copy my dev folder to VM that’s hosting the docker containers and then mounting wherever that folder is into the running containers. Too much indirection for me.

Vagrant to the rescue

I then remembered that vagrant¬†forwards local folders very nicely, and into a very predictable location. I also remembered that vagrant supports docker as a provisioner, even better a quick search turned up that there’s a docker-compose plugin for it as well.

I quickly built a very simple vagrant file:

Followed by vagrant up and, lo and behold, everything just worked.

What’s Happening?

  • The vagrantfile uses the basic ubunty box.
  • It then provisions by installing docker & docker-compose
  • The final two options on docker_compose are:
    • the docker-compose.yml to run (it allows multiples)
    • always run this provisioner, e.g. on vagrant reload

Finally to make my life easier I forward the ports on the vagrant box where my containers are running to my local machine.

The full project is available in GitHub.

VDLNMP: Vagrant-Docker-Linux-Nginx-MySQL-PHP