简体   繁体   中英

Docker TCP vs host port

can some one please help me on understanding this, I have a Dockerfile and dockercompose.yaml

When i do docker-compose up, I see the tcp being diffrent compared to the exposed ports, here is the file

> 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? 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. Just removed the Expose from Dockerfile and exposed the port via docker-compose yaml. All worked well

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM