nat - 如何用docker制作一个端口转发的镜像?
滿天的星座
滿天的星座 2017-04-25 09:01:35
0
2
805

比如我想把本地的8080端口转发到本地的9090端口,这个如何封装呢?端口都是宿主机之间转发,不需要转发到容器里面去,常用的一个场景就是将内网的数据库端口转发到公网上。

滿天的星座
滿天的星座

reply all(2)
習慣沉默

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-Pparameters

-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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!