Exposing container services
So far, we have successfully launched an HTTP service and accessed the service from the Docker host as well as another container within the same Docker host. Furthermore, as demonstrated in the Build images from containers section of Chapter 2, Handling Docker Containers, the container is able to successfully install the wget
package by making a connection to the publicly available apt repository over the Internet. Nonetheless, the outside world cannot access the service offered by a container by default. At the outset, this might seem like a limitation in the Docker technology. However, the fact of the matter is, the containers are isolated from the outside world by design.
Docker achieves network isolation for the containers by the IP address assignment criteria, as enumerated:
Assign a private IP address to the container, which is not reachable from an external network.
Assign an IP address to the container outside the host's IP network.
Consequently, the Docker...