有没有办法在Dockerfile中未能输出端口?
我试图通过Docker Image在我们的公司云中部署蚊子MQTT经纪人。暴露的允许端口在10000-10999范围内。 默认情况下,Eclipse-mosquitto图像公开了端口1883。是否有一种方法可以使端口1883并暴露10883? 这是我的 dockerfile :
FROM eclipse-mosquitto:latest
COPY mosquitto.conf /mosquitto/config/
COPY docker-entrypoint.sh mosquitto-no-auth.conf /
EXPOSE 10883
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/usr/sbin/mosquitto", "-c", "/mosquitto/config/mosquitto.conf"]
I am trying to deploy a mosquitto MQTT broker in our corporate cloud through docker image. The allowed ports that are exposed are in the range of 10000-10999.
By default eclipse-mosquitto image exposes port 1883. Is there a way to unexpose port 1883 and expose 10883?
This is my Dockerfile:
FROM eclipse-mosquitto:latest
COPY mosquitto.conf /mosquitto/config/
COPY docker-entrypoint.sh mosquitto-no-auth.conf /
EXPOSE 10883
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/usr/sbin/mosquitto", "-c", "/mosquitto/config/mosquitto.conf"]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅仅因为容器公开了端口1883,这并不意味着您需要使用访问运行实例所需的端口。
当您使用
Docker Run
命令启动容器时,您可以确定主机上的哪个端口被映射到容器上的该端口。例如
,这将使主机上的端口10883暴露于容器上的1883年。
Just because the container exposes port 1883 that doesn't mean that's the port you need to use access a running instance.
When you start the container using the
docker run
command you get to decide what port on the host machine is mapped to that port on the container.E.g.
This will expose port 10883 on the host and map it to 1883 on the container.
dockerfile 中的“Expose”是一种元数据,它告诉您应该使用哪个端口。它不打开任何端口。所以你可以轻松地打开任何你想要的端口。
"Expose" in dockerfile is kind of a meta data which tells which port you should work with. It does not open any port. So you can easily open any port you want.