title: How to automate multi server deployment using docker
body: <p>Here's my situation:</p>
  
  <ul>
  <li>I have a project written in Go stored on Github</li>
  <li>I have 3 app servers behind a load balancer (app1, app2, app3)</li>
  <li>I have a Dockerfile as part of the project in git, which when used to build an image, knows how to install all my app dependencies (including Go) and get a working environment for my app</li>
  <li>I have containers running on all 3 app servers and everything is working marvellously </li>
  </ul>
  
  <p>Now I want to change some code and redeploy my changes to those 3 servers. I can think of 3 possible ways to facilitate the automation of this:</p>
  
  <ol>
  <li>As part of my dockerfile I can add a step that pulls my code from Github and builds it. So to redeploy I need a script that logs into the 3 servers and rebuilds and runs the containers, thus pulling all new code in the process. At most all I ever need to push to a server is the Dockerfile.</li>
  <li>As part of my Dockerfile I can have an ADD command to bundle my code into the container. I would then need to deploy my entire project to each server using something like Capistrano or Fabric and then kill the old container, rebuild and run.</li>
  <li>I can use a nominated machine (or my dev environment) to build a new image based on the current source code. Then push this image to the registry. Then have a script which logs into my servers and pull the new image down, kill the old container and run the new one.</li>
  </ol>
  
  <p>Number 1 seems like the easiest but most other discussion I've read on Dockers leans towards a situation like 3 which seems rather long-winded to me. </p>
  
  <p>What is the best option here (or not here), I'm new to Docker so have I missed something? I asked someone who knows about Docker and their response was 'you're not thinking in the Docker way', so what's the Docker way?</p>