Linking Docker containers

In the older days of Docker, we were told to link containers using the --link option. With that option, Docker would create entries in /etc/hosts so that one container can refer to another container by its hostname. That option also arranged access to TCP ports and volumes between linked containers. This allowed the creation of multicontainer services, using private TCP ports for communication that exposed nothing to processes outside the containers.

Today, we are told that the --link option is a legacy feature, and that instead we should use bridge networks.  In this chapter, we'll focus solely on using bridge networks.

You can list the networks as follows:

$ docker network ls NETWORK ID          NAME                DRIVER              SCOPE 3021e2069278 ...

Get Node.js Web Development - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.