安装Setting Up Shared Database Container in Docker

The Objective

To setup a single database container that can be used with multiple applications and frontends.

Preparation

Method 1 - Container Links

This method utilizes the --link flag. Container links are a "legacy feature" of Docker and may become deprecated in a future release. Further reading https://docs.docker.com/network/links/

Method 2 - Docker Networking

Create a Docker network and connect each of the containers to it so they can communicate.

Method 3 - Exposing Host Ports

Expose ports on the host into the container and connect other containers to the host's exposed port