Skip to content

Development with Docker

Josh edited this page Feb 18, 2018 · 12 revisions

Debugging

Developing with Docker is just as comfortable as rbenv or rvm and the typical rails s and binding.pry or byebug workflow, and I find it more comfortable than foreman.

After getting the docker machines and services running with docker-compose up, you can attach to an individual service with:

docker attach limestone_{service}_1`

where {service} could be website. This will follow the server output and using pry or byebug will be interactive. You could also run docker attach limestone_sidekiq_1 to attach to the background processor.


Commands

To run rails/rake (same thing now) or bundler, you can use

docker-compose exec {service} rails ...`

For example, docker-compose exec website rails routes.

Bundler

Just running docker-compose exec website bundle will put the machine's Gemfile.lock in a bad state when restarting. The image will also need to be rebuilt with docker-compose up --build. It won't take as long as it did the first time because Docker layers are smart.


Stopping services

To stop services, ctrl+c from the terminal you wrote docker-compose up from will send the terminate signal to all running processes. There's a bug in Docker where sometimes it will instead output ERROR: Aborting. In this event, running docker-compose down will kill the still running processes.

To start your environment over, you can delete all volumes while shutting down with docker-compose down -v. This will delete your database and return your disk to it's original state. All uploads in the storage folder would be removed.

Learning more

If you want to know more about how Docker works (it's pretty neat), I recommend the Dive into Docker course by Nick Janetakis.

Clone this wiki locally