Easy Docker Setup in 3-2-1

I’ve recently graduated from Vagrant to docker for most of my development environments. I like it a lot.
The mixture of docker + alpine seems to get the job done well. It also allows to share configurations rather easily.
Here I’ll show you how I set up my docker environment in 3 easy steps.

I’ll also show you how i get around the slowness of OSX Docker Native

Steps

  1. Lets verify the basics: I am running Docker Native 1.12.5 (build 1477) on OSX 10.12.2.
  2. Verify that you have a recent ruby installed (Comes with OSX but you’d wanna brew yourself the most recent one) (you ¬†only need this if you’re going to use docker-sync)
  3. Install docker sync
     gem install docker-sync no-ri no-rdoc

Project structure

In general i like to have my project structure setup like so

Note about sample code:
The setup used by the gist is for a weird wordpress + mono combo, as i was porting an existing .NET application to WordPress.
Techniques are applicable to pretty much any stack. I am not including the Dockerfile as it has little to do with the process.

Things to change

  • Modify docker-compose.yml line 17 to give you app it’s own name
  • Modify line 45 to make sure it matches docker-sync.yml
  • Modify docker-sync.yml as needed the dest is where the folder will be mounted in your container
     127.0.0.1 app.dev

    in your

     /etc/hosts

    to make it resolve to your localhost

Usage

If you’re using docker-sync, run

 docker-sync-stack start

,otherwise

 docker-compose up -d

docker-sync-stack will boot up unison before running docker-compose up

Resources:

Share This: