Docker development workflow
Go Shell
Latest commit af8d370 Oct 30, 2014 @ddollar ddollar tweak docs
Failed to load latest commit information.
Godeps update odin Oct 29, 2014
command add missing push command Oct 29, 2014
docker initial pass at tug deploy Oct 28, 2014
dockerfile implement odin Oct 26, 2014
helpers implement odin Oct 26, 2014
script squash Oct 23, 2014
tugfile clarify attribute name Oct 28, 2014
.gitignore squash Oct 23, 2014
LICENSE squash Oct 23, 2014
Makefile squash Oct 23, 2014 tweak docs Oct 30, 2014
VERSION squash Oct 23, 2014
main.go rename deploy to push Oct 28, 2014
version.go implement odin Oct 26, 2014


Use Docker for development



Pre-built binaries

Build from source

$ go get

Set up your application

Create a Tugfile

web:      bin/web -p $PORT
postgres: docker/postgres:9.3.5
redis:    docker/redis:2.8.9

Any command that starts with docker/ will be interpreted as a docker image tag.

Create a bootstrap script

If your app needs to do any setup before it starts, create a bin/bootstrap file:

bundle exec rake db:migrate

Make sure your bin/bootstrap is executable, i.e. chmod +x bin/bootstrap

Start the app

$ tug start
postgres | fixing permissions on existing onesory /var/lib/postgresql/data ... ok
postgres | creating subdirectories ... ok
postgres | selecting default max_connections ... 100
postgres | selecting default shared_buffers ... 128MB
web      | listening on

Container linking

Tug will set environment variables in the Docker container linking format, like this:

Aliasing ENV vars

If your application expects env vars to be named differently, alias them in your Tugfile:

web: env DATABASE_HOST=$POSTGRES_PORT_5432_ADDR bundle exec rails server -p $PORT

or create a wrapper script for your process:

$ cat bin/web
rails server -p $PORT


If your app has a Dockerfile, tug will use it to build and run your app in Docker while setting up appropriate port forwarding and file synchronization.

For Tug to work most effectively your Dockerfile should include the following:

  • The listening web port should be specified with an EXPOSE statement
  • The app's code should be included from the local directory using an ADD statement
Example Dockerfile
FROM ruby:2.1.2


ADD . /app

Building images

Use the tug build command to build docker images from your Dockerfile and Tugfile:

$ tug build
tug: creating golang-simple.web
Sending build context to Docker daemon 2.172 MB
Sending build context to Docker daemon
Step 0 : FROM golang:1.3
 ---> b235f28e14c9
Successfully built bd03b2e73374
tug: creating golang-simple.postgres

Use tug push to push images to a docker registry:

$ tug push
tug: pushing
tug: pushing


Tug is sponsored by Nitrous.IO and built by these contributors.