Quick Recap

Let’s review what we have learned so far.

Highlights

We have introduced a powerful new tool into our arsenal: Docker Compose. It really is a one-stop-shop command for developing our app with Docker.

Let’s review what we covered in this chapter:

  1. We introduced the docker-compose.yml and its format.

  2. We created our own docker-compose.yml for our Rails app, including a locally mounted volume to allow live editing of local files.

  3. We saw how to spin up our entire app and start the Rails server by using the docker-compose up command.

  4. We learned various commands for managing our app with Compose:

    • List running containers.

      docker-compose ps
      
    • Manage the container life cycle.

      $ docker-compose [start|stop|kill|restart|pause|unpause|rm] <service name> 
      
    • View the logs.

      docker-compose logs [-f] <service name>
      
    • Run a one-off command in a new, throwaway container.

       docker-compose run --rm <service name> <some command> 
      
    • Run a one-off command in an existing container.

      docker-compose exec <service name> <some command>
      
    • Rebuild an image.

      docker-compose build <service name>
      

By making use of this Compose goodness, we have replaced our more complicated docker run commands with something clean, easy to remember, and manageable. We can now launch our entire app from scratch with just a single command. Hurrah! 🎉

What to expect in the next chapter?

Now it is time to start using Compose to extend the capabilities of our app by adding services.

Get hands-on with 1200+ tech skills courses.