- Suppose I use a web service (in any language) and a redis service. When I run the Redis service in docker, I map port 6379 so that the local web service can also use Redis.
- However, if you turn this around and run the Redis service locally, the port is 6379, and the docker runs the web service, will you not be able to access the external Redis service in the container at this time?
Because the container is independent of the host, communication needs to be established through the port, and the port 6379 of the Redis container is mapped out. The system will say that this port is occupied, stop the Redis service of the host, and the container can be started. However, when the Redis of the host is started, the system will also prompt that the port is occupied.
So I would like to ask, is it not possible to access the host’s services in the container? Because the container itself needs to occupy the port to communicate with the host, and the host of this port needs to start Redis, which is trapped in the deadlock of port occupation.
Use the IP of the host plus the port number link