Quick Recap

Let's review what we have covered in this chapter.

Highlights

The true power of using containers for our apps is not running a process in an individual container (though that is useful), but rather how we are able to wire containers together so they can talk to each other.

In this chapter, we have seen how we can add services to our application, running in separate containers. More importantly, we have seen how Docker’s built-in networking is used to let the services talk to each other.

Let’s review the highlights:

  1. We started a Redis server in a container using docker run. We covered two new options: --name for giving containers a human-friendly name, and -d for running a container in detached mode.

  2. We added a separate service in Compose for running the Redis server.

  3. We verified that the Redis server was running and that we could connect to it from a separate container by starting a new container to run redis-cli.

  4. We discussed the networking features Docker provides and how Compose facilitates containers talking to each other.

  5. We connected our Rails app to the Redis server, making it store and increment a value, which we then retrieved and displayed.

  6. Finally, we saw that our trusty docker-compose up works, and will start up both the Rails and Redis servers in one go.

What to expect in the next chapter?

Next, we are going to take what we have learned about Compose and use it to add a Postgres database. We will go a step further and see how to ensure our data persists even if the container running our database was deleted.

Get hands-on with 1200+ tech skills courses.