Skip to content

Instantly share code, notes, and snippets.

@lazyatom
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazyatom/9221883 to your computer and use it in GitHub Desktop.
Save lazyatom/9221883 to your computer and use it in GitHub Desktop.
Austin on Rails - play around with Docker

If you'd like a taste of Docker, here's how to get my silly Taco app running under Docker on your machine.

First, install docker-osx

... using instructions from https://github.com/noplay/docker-osx

curl https://raw.github.com/noplay/docker-osx/0.8.0/docker-osx > /usr/local/bin/docker-osx
chmod +x /usr/local/bin/docker-osx

Then start the docker VM

docker-osx shell
docker version

If everything works OK, keep going.....

Set a name for the database container

export DB_CONTAINER_NAME=test_app_db

Start the database container.

This pulls down the orchardup/postgresql container automatically.

docker run -d \
  -name $DB_CONTAINER_NAME \
  -p 5432:5432 \
  -e POSTGRESQL_USER=docker_rails_app \
  -e POSTGRESQL_PASS=pa$$w0rd \
  -e POSTGRESQL_DB=docker_rails_app_production orchardup/postgresql

Create the database.

This will automatically pull down the lazyatom/docker-rails-app container I built and pushed for the talk

docker run -link $DB_CONTAINER_NAME:db lazyatom/docker-rails-app rake db:schema:load

Check everything works with the console

docker run -link $DB_CONTAINER_NAME:db -t -i lazyatom/docker-rails-app rails c

You should be able to run Taco.count and get 0.

Start the web server

docker run -d \
  -p 6789:5000 \
  -link $DB_CONTAINER_NAME:db \
  lazyatom/docker-rails-app

Then visit http://localdocker:6789/tacos - and rejoice! (note it's localdocker, not localhost)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment