Difficulty: Beginner
Estimated Time: 10 minutes

This scenario explores how to allow multiple containers to communicate with each other. The steps will explain how to connect a data-store, in this case, Redis, to an application running in a separate container.

This environment has been configured with a Docker client and daemon. The machine name the Docker daemon is running on is called docker. If you want to access any of the services, then use docker instead of localhost or 0.0.0.0.

In this scenario we've explored how Docker links work and how you can connect and communicate between two containers. You can use the same approach to connect multiple containers together.

Don’t stop now! The next scenario will only take about 10 minutes to complete.

Communicating Between Containers

Step 1 of 4

Step 1 - Start Redis

The most common scenario for connecting to containers is an application connecting to a data-store. The key aspect when creating a link is the name of the container. All containers have names, but to make it easier when working with links, it's important to define a friendly name of the source container which you're connecting too.

Start Data Store

Run a redis server with a friendly name of redis-server which we'll connect to in the next step. This will be our source container.

docker run -d --name redis-server redis

Redis

Redis is a fast, open source, key-value data store.