Can docker access the host service through the container?

< H2 > problem description < / H2 >
  • suppose I use a web service (in any language) and a Redis service, and when I run the redis service in docker, map out port 6379 so that the local web service can also use Redis.
  • but on the other hand, if you run the Redis service locally, and the port is also 6379 running the web service in the docker, is it impossible to access the external Redis service in the container?
< H2 > questions < / H2 >

because the container is independent from the host, you need to establish communication through the port and map port 6379 of the Redis container. The system will say that this port is occupied, the Redis service of the host is stopped, and the container can be started. However, when you start the Redis of the host, it will also indicate that the port is occupied.

so I would like to ask whether it is not possible to access the host service within the container. Because the container itself needs to occupy the port to communicate with the host, and the host of this port wants to start Redis, it falls into a dead knot in which the ports occupy each other.

Jun.09,2022

just add the port number link to the IP of the host

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e90685-12d9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e90685-12d9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?