[英]How to access a Process running on docker on a host from a remote host
How to access or connect to a process running on docker on host A from a remote host B 如何从远程主机B访问或连接到主机A的docker上运行的进程
consider a Host A with ip 192.168.0.3 which is running a application on docker on port 3999 . 考虑一个IP地址为192.168.0.3的主机A,该主机在docker的3999端口上运行一个应用程序。 If i want to access that application from remote machine with IP 192.168.0.4 in same subnet.
如果我想从IP地址为192.168.0.4的远程计算机访问同一子网中的应用程序。
To be precise i am running Kafka producer on the server and i am trying to receive using Kafka-console-Consumer. 确切地说,我正在服务器上运行Kafka生产者,并且尝试使用Kafka-console-Consumer进行接收。
--net=host
to run
your container and it'll use the host's network stack, then you can connect to the application running inside container like it's running on host directly. --net=host
run
您的容器,它将使用主机的网络堆栈,然后您可以连接到在容器内部运行的应用程序,就像它直接在主机上运行一样。 -p
to map the port inside your container to a port of your host. -p
将容器内的端口映射到主机的端口。 eg docker run -d -p <container port>:<host port> <image>
, then you can connect to <host>:<host port>
to connect your application inside container docker run -d -p <container port>:<host port> <image>
,然后您可以连接到<host>:<host port>
将应用程序连接到容器中 Hope this is helpful :-) 希望这会有所帮助:-)
First you need to bind docker container's port to the Host A: 首先,您需要将Docker容器的端口绑定到主机A:
docker run -d -p 3999:3999 kafka-producer
码头工人运行-d -p 3999:3999 kafka-producer
Then you need to access Host A from Host B using IP:Port 然后,您需要使用IP:Port从主机B访问主机A。
192.168.0.3:3999
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.