I have a Windows host running a RHEL 8 VM that is running multiple Docker containers. I created the Docker network and assigned static IPs for each container. The VM can access each container endpoints. However, the Windows host and anything outside cannot. Is it possible to create a subnet that will allow applications from the outside to communicate with the containers?
Each of these container is acting as a routing device to receive data from an external application. The external app needs to be able to send the data to the IP that correspond to the container.
NOTE: currently not using docker-compose
2
Answers
Here’s a step-by-step setting up a subnet for Docker containers in a Rhel 8 VM on a Windows host, to allow external applications to communicate with these containers:
External connectivity in docker is managed by publishing ports ports.
Yes, containers with static IPs can be accessed from the host OS. This is not an intended feature, this is an implementation detail of bridge networks.
If you do insist on using this detail, then be aware that its going to work only on docker engine installs, Docker Desktop is not going to help expose the containers from the Moby vm to the host. Because it is not actually a feature of Docker.