比如我想把本地的8080端口轉(zhuǎn)發(fā)到本地的9090端口,這個(gè)如何封裝呢?端口都是宿主機(jī)之間轉(zhuǎn)發(fā),不需要轉(zhuǎn)發(fā)到容器里面去,常用的一個(gè)場(chǎng)景就是將內(nèi)網(wǎng)的數(shù)據(jù)庫端口轉(zhuǎn)發(fā)到公網(wǎng)上。
Your description is really hard to understand. The local port is forwarded to the local port. What is this "local" designation, the container or the host?
For mapping the container port to the host, can't the -p parameter be easily implemented?
docker run ... -p 13306:3306 mysql
Doesn’t this map the 3306 port of the container MySQL service to the 13306 port of the host? External access to port 13306 can connect to the database.
As mentioned above, docker supports port mapping from container to host, using the official -p
或-P
parameters
-P : Publish all exposed ports to the host interfaces
-p=[] : Publish a container?s port or a range of ports to the host
For details, please refer to the official website instructions: https://docs.docker.com/engin...
As for the local-to-local port mapping you described, it should not be a function of Docker.