Accessing containers from outside
In the microservice architecture, multiple smaller services are used to provide a meaningful enterprise-grade application. The Docker-inspired containerization technology is inherently very lightweight, and hence it plays a vital role in enabling the microservice architecture. By default, the Docker container allows outgoing data traffic, but there is no path for the external world to connect to the services running inside the container. Nonetheless, Docker provides an elegant solution to selectively enable the external world to communicate with the service running inside the container, using the following options of the docker container run
command:
| Publish a container's port to the host |
| Publish all exposed ports to random ports |
Both these options allow the external world to connect to the services running inside the containers through the ports of the Docker host.
Getting ready
Before we begin, make sure the Docker daemon is...