The difference between Docker and Docker Compose

by Jason Swett,

When I first started trying to learn how to Dockerize a Rails application, I confused by the difference between Docker Compose. Many writings I came across mentioned Docker Compose but they didn’t really explain what it was.

Background: development vs. production

First, a little bit of background. There are two ways to Dockerize an application. You can either use Docker to help with your development environment or your production environment.

Docker Compose is a tool that helps with your development environment. Docker Compose does not apply to production environments.

Let’s talk specifically about how Docker Compose can help with a development environment.

How Docker Compose helps development environments

For a Rails app, running a development environment is not as simple as just running rails server. In addition to the Rails server, you might have to run other services including an RDBMS (e.g. PostgreSQL), a key/value data store (e.g. Redis), a worker (i.e. the service that handles background jobs) and possibly webpack-dev-server.

Installing and running all these services manually can be tedious. Plus remember that not only do you have to run all this stuff, but you have to somehow know what all the things your app needs to run are.

Docker Compose gives you a way to say “Hey, my app uses PostgreSQL, Redis, a worker instance, and webpack-dev-server. Install all that stuff and run it for me.” As long as you have your Docker Compose config file set up properly, you can run the docker-compose up command and it will do all that for you.

Takeaways

  • There are two ways to Dockerize an app: for development and for production.
  • Docker Compose helps Dockerize an app for development.
  • Docker Compose provides a way to specify what services your development environment needs in order to function properly. Once configured, Docker Compose can install and run your services for you.

Leave a Reply

Your email address will not be published. Required fields are marked *