Using Docker local networking
Both Docker and Docker Compose have command-line options to specify a Docker local network that the application will use. Using this Docker local network allows our containers to access another container's ports without having to bind/expose these ports to the host's ports.
Networking using .sh scripts
You use the docker network create
command to create a named network that your containers can use to privately communicate with one another. You can have as many of these private networks defined as you like—you might want to work on multiple unrelated projects simultaneously and each needs its own network:
% docker network create chapter4
This command creates a network named chapter4
that we can use for our microservices example programs. We can destroy networks we have created using the docker network rm
command:
% docker network rm chapter4
This command removes our chapter4
network from the system.
The start-mongodb...