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.
Communicating Between Containers
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 to.
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 is a fast, open source, key-value data store.