The challenge of provisioning a flexible, agile development environment is one we are always thinking about here at Simbco. Having a quick way to spin up new environments using a variety of technologies, while ensuring they are properly modular, can have a powerful impact on the overall speed and quality of technical work for a team, so it’s a challenge well worth investing in.
This week, we are kicking off development on a new project using an AngularJS interface that loads data through an API, generated with a Rails app. In the past, I have used Vagrant and Ansible to provision a development environment, but have found that the Vagrant container can be a bit of a wall and the process sometimes clunky. In the interest of exploring the idea of a more transparent, unobtrusive container environment, I have been doing a lot of work with provisioning and deploying private clouds using Docker and decided this would be a great opportunity to switch out our Vagrant process for one using Docker.
I won’t slog through the gory details of setting up this environment because the fellas over at Fig have done it so very nicely for us. You can use this tutorial here to setup a rails environment which is linked to a Postgres database container. Pretty slick.
Except, after following the tutorial I wasn’t able to connect to Docker on port 3000. After confirming that my containers and processes were up and running and still not being able to connect, I tracked down the problem. It was because of an update to the address rails binds to in the 4.2 release (see section 3.3 Default Host for Rails server). The default host is now bound specifically to “localhost” which means its not listening for the traffic requests that are being forwarded in via our Boot2Docker image. But by changing the startup command in our fig.yml we can fix this issue and get access to our Rails server running in the Docker container.
command: bundle exec rails server -b 0.0.0.0
In the interest of saving someone else some time when trying to use Fig to setup a Rails Docker environment, I set up a github repository to simplify the process of starting this kind of application. Feel free to leave feedback on github – we are all about incremental improvements.