[英]Docker TCP vs host port
can some one please help me on understanding this, I have a Dockerfile and dockercompose.yaml有人可以帮助我理解这一点吗,我有一个 Dockerfile 和 dockercompose.yaml
When i do docker-compose up, I see the tcp being diffrent compared to the exposed ports, here is the file当我做 docker-compose 时,我看到 tcp 与暴露的端口相比有所不同,这是文件
> Dockerfile
FROM msridhara/tomcat
VOLUME /tmp
CMD ["catalina.sh","run"]
EXPOSE 81
>docker-compose.yaml
version: '2'
services:
web:
image: msridtomcat
build: .
container_name: mcontainer
restart: always
volumes:
- /home/murali/website/containerjob/war/:/usr/local/tomcat/webapps/
# - /home/ubuntu/webimage/index.html:/var/www/html/index.html
ports:
- "81:8080"
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2cb36ee8c5ee msridtomcat "catalina.sh run" 58 seconds ago Up 57 seconds 83/tcp, 0.0.0.0:81->8080/tcp mcontainer
Please see the 83/tcp?请看83/tcp? from where it is coming?
它从哪里来?
docker inspect -- results in
"NetworkSettings": {
"Bridge": "",
"SandboxID": "397ab289e556f8ee4b92c47e806a11a1f76d53cb398bdd5701e10e20a3362882",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"8080/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "81"
}
],
"83/tcp": null
},
Thanks Murali谢谢穆拉利
This tcp 83 is due to Expose 83 in Dockerfile.这个 tcp 83 是由于 Dockerfile 中的 Expose 83 造成的。 Just removed the Expose from Dockerfile and exposed the port via docker-compose yaml.
刚刚从 Dockerfile 中删除了 Expose,并通过 docker-compose yaml 暴露了端口。 All worked well
一切运作良好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.