What I've learned by Dockerise a Rails app

on 2015-04-10

First thing was to Dockerise an Erlang pub/sub server. The problem is that application can only be started in console or daemon mode. So let's use some shell tricks to wait daemon.

start # start daemon
child=$! # keep the pid in child variable
wait ${child} # wait daemon process finish

The application also need to have database ready on boot. This is not possible with docker because the containers are just started without dependency. However, there is a trick with links by using docker-wait.

mongodbready:
  image: aanand/wait
  links:
    - mongodb

app:
  image: app
  links:
    - mongodbready
    - mongodb

Dockerfile ADD instruction handle URL with cache support. It's useful when you have to get a source tarball.

docker-compose can handle env files like dotenv project, and pretty useful when you have a Rails container and a sidekiq container that shares the same environment.