问题描述
如何将UDP端口从Docker容器转发到主机?
使用-p标志并在端口号中添加 / udp
后缀。
-p 53160:53160 / udp
完整命令
sudo docker run -p 53160:53160 \
-p 53160:53160 / udp -p 58846:58846 \
-p 8112:8112 -t -i aostanin / deluge /start.sh
如果在Mac上运行boot2docker,请确保将boot2docker上的相同端口转发到本地计算机。
您还可以记录该容器需要使用 Dockerfile中的接收UDP
(EXPOSE不会发布端口):
EXPOSE 8285 / udp
此处是容器文档中包含更多Docker网络信息的链接:
(由Old Pro提供) / p>
How do I forward a UDP port from my Docker container to the host machine?
Use the -p flag and add /udp
suffix to the port number.
-p 53160:53160/udp
Full command
sudo docker run -p 53160:53160 \
-p 53160:53160/udp -p 58846:58846 \
-p 8112:8112 -t -i aostanin/deluge /start.sh
If you're running boot2docker on Mac, be sure to forward the same ports on boot2docker to your local machine.
You can also document that your container needs to receive UDP using EXPOSE in The Dockerfile
(EXPOSE does not publish the port):
EXPOSE 8285/udp
Here is a link with more Docker Networking info covered in the container docs:https://docs.docker.com/config/containers/container-networking/(Courtesy of Old Pro in the comments)
这篇关于如何在Docker上发布UDP端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!