如何使用docker-compose发布端口(网桥默认网络)

时间:2018-06-15 12:48:48

标签: docker docker-compose

我无法联系我的docker-compose.yml

中声明的任何服务

所有连接都已超时并且我没有看到使用tcpdump的流量但是在使用netstat时所有端口似乎都已打开

这是我的docker-compose.yml

version: '3'
services:
  just_teacher:
    image: just_teacher
    build:
      context: ./teacher
      dockerfile: Dockerfile_teacher_
    ports:
        - "5002:5002"
    container_name: just_teacher
    network_mode: bridge

  just_teacher_consumer:
    image: just_teacher_consumer
    build:
      context: ./teacher
      dockerfile: Dockerfile_teacher_vote_consumer_
    container_name: just_teacher_consumer
    network_mode: bridge

  just_controller:
    image: just_controller
    build:
      context: ./controller
      dockerfile: Dockerfile_controller_
    container_name: just_controller
    ports:
        - "5010:5010"
    network_mode: bridge

  just_controller_consumer:
    image: just_controller_consumer
    build:
      context: ./controller
      dockerfile: Dockerfile_controller_consumer_
    container_name: just_controller_consumer
    network_mode: bridge

  just_reccomender:
    image: just_reccomender
    build:
      context: ./reccomender_news
      dockerfile: Dockerfile_reccomender_
    container_name: just_reccomender
    ports:
        - "5020:5020"
    network_mode: bridge

  just_reccomender_consumer:
    image: just_reccomender_consumer
    build:
      context: ./reccomender_news
      dockerfile: Dockerfile_reccomender_consumer_
    container_name: just_reccomender_consumer
    network_mode: bridge

  just_rss_consumer:
    image: just_rss_consumer
    build:
      context: ./just-server
      dockerfile: Dockerfile_rss_consumer_
    container_name: just_rss_consumer
    volumes:
        - /data:/data
    network_mode: bridge

  just_server:
    image: just_server
    build:
      context: ./server
      dockerfile: Dockerfile_
    container_name: just_server
    volumes:
        - /data:/data
    ports:
        - "28050:28050"
        - "8087:8087"
        - "8060:8060"
        - "8050:8050"
    restart: always
    network_mode: bridge

  just_scheduler_feed:
    image: just_scheduler_feed
    build:
      context: ./server
      dockerfile: Dockerfile_Scheduler_Feed_
    container_name: just_scheduler_feed
    network_mode: bridge

  just_scheduler_objects:
    image: just_scheduler_objects
    build:
      context: ./server
      dockerfile: Dockerfile_Scheduler_Objects_
    container_name: just_scheduler_object
    network_mode: bridge

  just_scheduler_travel:
    image: just_scheduler_travel
    build:
      context: ./server
      dockerfile: Dockerfile_Scheduler_Travel_
    container_name: just_scheduler_travel
    network_mode: bridge

  just_scheduler_social:
    image: just_scheduler_social
    build:
      context: ./server
      dockerfile: Dockerfile_Scheduler_Social_
    container_name: just_scheduler_social
    network_mode: bridge

  just_metric:
    image: just_metric
    build:
      context: ./metric
      dockerfile: Dockerfile_metric_
    container_name: just_metric
    ports:
        - "5005:5005"
    network_mode: bridge

  just_metric_consumer_vote:
    image: just_metric_consumer_vote
    build:
      context: ./metric
      dockerfile: Dockerfile_consumer_metric_vote_
    container_name: just_metric_consumer_vote
    network_mode: bridge

  just_metric_consumer_container:
    image: just_metric_consumer_container
    build:
      context: ./metric
      dockerfile: Dockerfile_consumer_metric_container_
    container_name: just_metric_consumer_container
    network_mode: bridge

  just_metric_consumer_user_info:
    image: just_metric_consumer_user_info
    build:
      context: ./metric
      dockerfile: Dockerfile_consumer_metric_user_info_
    container_name: just_metric_consumer_user_info
    network_mode: bridge


  just_social:
    image: just_social
    build:
      context: ./social
      dockerfile: Dockerfile_social_
    container_name: just_social
    ports:
        - "6789:6789"
    network_mode: bridge

  just_social_consumer:
    image: just_social_consumer
    build:
      context: ./social
      dockerfile: Dockerfile_social_consumer_
    container_name: just_social_consumer
    network_mode: bridge

docker network inspect output

[
    {
        "Name": "bridge",
        "Id": "30ef10e3971151145931f08666677f77df4471927832b457e4792c3f46479e21",
        "Created": "2018-06-15T13:11:36.014987501+02:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.17.0.0/16",
                    "Gateway": "172.17.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "Containers": {
            "076daa201d090133bba9f8f5ed3dd050f33f06d2ee59512f4776bfe2bb1c532d": {
                "Name": "just_rss_consumer",
                "EndpointID": "d4ac24885570fbffeafb0b793b92c1970014eedbc77cb71e8561c0975749f0d5",
                "MacAddress": "02:42:ac:11:00:0d",
                "IPv4Address": "172.17.0.13/16",
                "IPv6Address": ""
            },
            "2024fec5d0581051cc7bc27fa03a353b4829a0a93248ce6d50a657973a4d0934": {
                "Name": "just_scheduler_social",
                "EndpointID": "88e5159284e872b7bc9f670ada503b2d4dd8985964d3c4237aeb8f7267d9a20a",
                "MacAddress": "02:42:ac:11:00:13",
                "IPv4Address": "172.17.0.19/16",
                "IPv6Address": ""
            },
            "30e4bf7a098436786ca91de245400d7022f542e825d4da65909d26d21c995b33": {
                "Name": "just_controller",
                "EndpointID": "298a994caaa5e508a5b4865c30452d358ecd6115553ea79f1bdb488b786a471a",
                "MacAddress": "02:42:ac:11:00:08",
                "IPv4Address": "172.17.0.8/16",
                "IPv6Address": ""
            },
            "3f039e893196c0438a610424bc19f42b9d861aa085077940e073d1bbf37d3878": {
                "Name": "just_metric_consumer_container",
                "EndpointID": "c4df111bfe78a5585a20160165aeaaa6a9aefd018787f2538249aeb045e23743",
                "MacAddress": "02:42:ac:11:00:10",
                "IPv4Address": "172.17.0.16/16",
                "IPv6Address": ""
            },
            "5157ac753b38f94f9d852c94d1f3be5b886827e0c02163184c3510cb1f251426": {
                "Name": "just_teacher",
                "EndpointID": "f985bd9f71e5f6e9e6c89262e5ace6531ba04c8f615299feab5e881edc4a2acb",
                "MacAddress": "02:42:ac:11:00:02",
                "IPv4Address": "172.17.0.2/16",
                "IPv6Address": ""
            },
            "61f8513310b0e222fbb73ce4e7d7fb42aa72ac00fb888c692d6b2936e1161c06": {
                "Name": "just_scheduler_feed",
                "EndpointID": "312b484156a7ddc3aea082bb1032e02b24edd310bad4d8e8eedfefe57e83a6ca",
                "MacAddress": "02:42:ac:11:00:0b",
                "IPv4Address": "172.17.0.11/16",
                "IPv6Address": ""
            },
            "7366522d028ebf3ec9926b79bb71b54122d5a80c5806310c32a2dd29eba5c103": {
                "Name": "just_controller_consumer",
                "EndpointID": "e2fe21d33f5ba6bd23f5055bea208329d76dbf52166911e61b38dc0ba441f298",
                "MacAddress": "02:42:ac:11:00:03",
                "IPv4Address": "172.17.0.3/16",
                "IPv6Address": ""
            },
            "8268526364d5ec08b1c5e2ebc5acd2427eb8eaf8e8769307a5aa9eb9d90a940a": {
                "Name": "just_metric",
                "EndpointID": "2df8952934e8a850cc87b34b3374028a1af8af876af7aa7253f321377669aa79",
                "MacAddress": "02:42:ac:11:00:0c",
                "IPv4Address": "172.17.0.12/16",
                "IPv6Address": ""
            },
            "835e4f11251c127a33f7d6e449140103e1a907e753ef190916f3dde4bc07a528": {
                "Name": "just_reccomender_consumer",
                "EndpointID": "d0d4d8600026043c05e49edb59c97a62962cfd7c7901d5fb084236a50a79f24a",
                "MacAddress": "02:42:ac:11:00:06",
                "IPv4Address": "172.17.0.6/16",
                "IPv6Address": ""
            },
            "8c6eca8f61aaa15ca1a48942e50cf00d262184726d2d9605972e86fb80f1f07d": {
                "Name": "just_social",
                "EndpointID": "ae235fe1e59c3bdabd73f104f1959828b60ee01714446176c0cf0b7f674934f7",
                "MacAddress": "02:42:ac:11:00:07",
                "IPv4Address": "172.17.0.7/16",
                "IPv6Address": ""
            },
            "9aeb9955f3d97d03884edd51775ef05c0aefa4470aaa544750149d17931cf615": {
                "Name": "just_metric_consumer_vote",
                "EndpointID": "f8cd4fe4d36910e1137dd58d8f229ce8926d49e21c8996c7f0139402d69266b3",
                "MacAddress": "02:42:ac:11:00:0e",
                "IPv4Address": "172.17.0.14/16",
                "IPv6Address": ""
            },
            "9c3b982fa71df2745dcbf72f17ff1071e0d8e2929331c4679b19f29861b7b303": {
                "Name": "just_scheduler_object",
                "EndpointID": "d627a091b153beafeb221fce536d0675fd523da97cb7241c102df70cc28332b2",
                "MacAddress": "02:42:ac:11:00:05",
                "IPv4Address": "172.17.0.5/16",
                "IPv6Address": ""
            },
            "bb15d3eea528972dfc2eb177e0369539b0df3c1e51c28574f39d05ae7d30a009": {
                "Name": "just_social_consumer",
                "EndpointID": "a738a1ec6ae7e133ea17105591173f883ec6435a76d26539ddc0af331254c7f6",
                "MacAddress": "02:42:ac:11:00:0f",
                "IPv4Address": "172.17.0.15/16",
                "IPv6Address": ""
            },
            "d0f0aa795fd17a4d692ff53224c51e49fec30a4d27f52d71bd2b7ea909e0db2c": {
                "Name": "just_scheduler_travel",
                "EndpointID": "204db8ce5f2d0e782a77bd3f70d1a475ed49110ab8dc92c350a52da1eabd56af",
                "MacAddress": "02:42:ac:11:00:0a",
                "IPv4Address": "172.17.0.10/16",
                "IPv6Address": ""
            },
            "eab8ba6d88875052997faf7c5c843910b1e9d26618768254ba157bfa809e301b": {
                "Name": "just_teacher_consumer",
                "EndpointID": "45fc12d0ed1fe516c67d5a1745fcacd0ca97da7e2ce0cee6a596884e08316a99",
                "MacAddress": "02:42:ac:11:00:11",
                "IPv4Address": "172.17.0.17/16",
                "IPv6Address": ""
            },
            "ec79e0733ae049308b80c3b75bc05a0919fbdb2b3e3d99531ce8f06df6698d58": {
                "Name": "just_reccomender",
                "EndpointID": "594419d39deec90f0f65cb5ca592432b23a376d1a1b28d02ba3a57cdf638b457",
                "MacAddress": "02:42:ac:11:00:12",
                "IPv4Address": "172.17.0.18/16",
                "IPv6Address": ""
            },
            "ec93841f66307f73f713a92f33eaeb1f84cfbd2bbdaa6d35a423d6190acca656": {
                "Name": "just_metric_consumer_user_info",
                "EndpointID": "d7dcb848e89d5f6cbb68dc0e015c33a6005427d4b1923e0a68309d52fa61c118",
                "MacAddress": "02:42:ac:11:00:09",
                "IPv4Address": "172.17.0.9/16",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.bridge.default_bridge": "true",
            "com.docker.network.bridge.enable_icc": "true",
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
            "com.docker.network.bridge.name": "docker0",
            "com.docker.network.driver.mtu": "1500"
        },
        "Labels": {}
    }
]

netstat输出

Connessioni Internet attive (solo server)
Proto CodaRic CodaInv Indirizzo locale        Indirizzo remoto       Stato       PID/Program name    
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:4369            0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:8050            0.0.0.0:*               LISTEN      27840/crossbar-work 
tcp        0      0 0.0.0.0:28050           0.0.0.0:*               LISTEN      27840/crossbar-work 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:8087            0.0.0.0:*               LISTEN      27840/crossbar-work 
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:15672           0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:8888            0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:8889            0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:8060            0.0.0.0:*               LISTEN      27840/crossbar-work 
tcp        0      0 0.0.0.0:24224           0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:24230         0.0.0.0:*               LISTEN      -                   
tcp        0      0 10.1.1.245:2375         0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:25672           0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:27017           0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:5355            0.0.0.0:*               LISTEN      -                   
tcp6       0      0 :::111                  :::*                    LISTEN      -                   
tcp6       0      0 10.1.1.245:9200         :::*                    LISTEN      -                   
tcp6       0      0 :::80                   :::*                    LISTEN      -                   
tcp6       0      0 :::4369                 :::*                    LISTEN      -                   
tcp6       0      0 :::5010                 :::*                    LISTEN      -                   
tcp6       0      0 10.1.1.245:9300         :::*                    LISTEN      -                   
tcp6       0      0 :::22                   :::*                    LISTEN      -                   
tcp6       0      0 ::1:631                 :::*                    LISTEN      -                   
tcp6       0      0 :::8889                 :::*                    LISTEN      -                   
tcp6       0      0 :::5020                 :::*                    LISTEN      -                   
tcp6       0      0 :::6789                 :::*                    LISTEN      -                   
tcp6       0      0 :::5672                 :::*                    LISTEN      -                   
tcp6       0      0 :::5002                 :::*                    LISTEN      -                   
tcp6       0      0 :::5355                 :::*                    LISTEN      -                   
tcp6       0      0 :::5005                 :::*                    LISTEN      -                   
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           -                   
udp        0      0 0.0.0.0:5355            0.0.0.0:*                           -                   
udp        0      0 0.0.0.0:24224           0.0.0.0:*                           -                   
udp        0      0 0.0.0.0:65488           0.0.0.0:*                           -                   
udp        0      0 127.0.0.53:53           0.0.0.0:*                           -                   
udp        0      0 0.0.0.0:111             0.0.0.0:*                           -                   
udp        0      0 172.17.0.1:123          0.0.0.0:*                           -                   
udp        0      0 10.1.1.245:123          0.0.0.0:*                           -                   
udp        0      0 127.0.0.1:123           0.0.0.0:*                           -                   
udp        0      0 0.0.0.0:123             0.0.0.0:*                           -                   
udp        0      0 0.0.0.0:631             0.0.0.0:*                           -                   
udp        0      0 0.0.0.0:782             0.0.0.0:*                           -                   
udp6       0      0 :::5353                 :::*                                -                   
udp6       0      0 :::5355                 :::*                                -                   
udp6       0      0 :::12935                :::*                                -                   
udp6       0      0 :::111                  :::*                                -                   
udp6       0      0 fe80::34dd:50ff:fea:123 :::*                                -                   
udp6       0      0 fe80::4419:96ff:fe9:123 :::*                                -                   
udp6       0      0 fe80::8c9a:46ff:fe0:123 :::*                                -                   
udp6       0      0 fe80::5c3c:5cff:fe2:123 :::*                                -                   
udp6       0      0 fe80::33:5fff:fed0::123 :::*                                -                   
udp6       0      0 fe80::4ca3:39ff:fe7:123 :::*                                -                   
udp6       0      0 fe80::640a:cff:fe74:123 :::*                                -                   
udp6       0      0 fe80::4cc3:49ff:fe3:123 :::*                                -                   
udp6       0      0 fe80::a4b4:24ff:fe2:123 :::*                                -                   
udp6       0      0 fe80::b08a:c5ff:feb:123 :::*                                -                   
udp6       0      0 fe80::a04f:a6ff:fe4:123 :::*                                -                   
udp6       0      0 fe80::1847:33ff:fe2:123 :::*                                -                   
udp6       0      0 fe80::e823:8eff:fef:123 :::*                                -                   
udp6       0      0 fe80::b8e9:f9ff:fe7:123 :::*                                -                   
udp6       0      0 fe80::18db:dff:fe12:123 :::*                                -                   
udp6       0      0 fe80::2443:5fff:fe0:123 :::*                                -                   
udp6       0      0 fe80::706c:13ff:fe2:123 :::*                                -                   
udp6       0      0 fe80::42:14ff:fe66::123 :::*                                -                   
udp6       0      0 fe80::65f:a479:51e8:123 :::*                                -                   
udp6       0      0 ::1:123                 :::*                                -                   
udp6       0      0 :::123                  :::*                                -                   
udp6       0      0 :::782                  :::*                                - 

我也禁用了。

我怎么解决?

提前致谢

已更新

docker ps -a output

CONTAINER ID                                                       IMAGE                                   COMMAND                                                                                                           CREATED             STATUS                      PORTS                                                                                              NAMES
9b7a1a9bfa5647456132dea8c321e461af68ac759a92a673593757d146883137   just_reccomender                        "/bin/sh -c 'python main.py'"                                                                                     32 minutes ago      Up 32 minutes               0.0.0.0:5020->5020/tcp                                                                             just_reccomender
e4ac56ef1ec6f66cc4320884001309423146ce781b9829718ea80a7595f14c25   just_scheduler_travel                   "/bin/sh -c 'python SchedulerTravel.py'"                                                                          32 minutes ago      Up 32 minutes                                                                                                                  just_scheduler_travel
0ebdee6414010c4bad80b81987fda843941e4b0cf7ffa1553bff7b6ffea29374   just_metric_consumer_user_info          "/bin/sh -c 'python consumer/user_info_consumer.py'"                                                              32 minutes ago      Up 32 minutes                                                                                                                  just_metric_consumer_user_info
2e3d1a7cff81096886d1d55ff1ab8f7fcc41af02fdb0fa22245ff500e28aa760   just_metric_consumer_container          "/bin/sh -c 'python consumer/container_consumer.py'"                                                              32 minutes ago      Up 32 minutes                                                                                                                  just_metric_consumer_container
c2d5bf9629311326e7db293a49da3d46cf2fac275599c315651cae593ffdd33d   just_metric                             "/bin/sh -c 'python main.py'"                                                                                     32 minutes ago      Up 32 minutes               0.0.0.0:5005->5005/tcp                                                                             just_metric
1e50b37952871745734a8e02b7e0604ad977d27849f15534c3800ec50684e264   just_reccomender_consumer               "/bin/sh -c 'python consumer/reccomandations_consumer.py'"                                                        32 minutes ago      Up 32 minutes                                                                                                                  just_reccomender_consumer
0fc7b0ab6d486854aeb2e3db8d8e115e83379cd99b482e5f400833937c03ff26   just_controller                         "/bin/sh -c 'python main.py'"                                                                                     32 minutes ago      Up 32 minutes               0.0.0.0:5010->5010/tcp                                                                             just_controller
418c8a26fa6db83909bfae993774b231e4252d4f5937045db1294b2af3de5a68   just_rss_consumer                       "/bin/sh -c 'python consumer_rss.py'"                                                                             32 minutes ago      Up 32 minutes                                                                                                                  just_rss_consumer
e91b01d5fc61017ad61da3d8ad70d427ec971df5561a752a5fb38e6a8731b513   just_controller_consumer                "/bin/sh -c 'python consumer/reccomendations_consumer.py'"                                                        32 minutes ago      Up 32 minutes                                                                                                                  just_controller_consumer
a16082943a9ac47d1720f05042b0e62f57cc980b0f135f137c4ed5e8747cd13c   just_metric_consumer_vote               "/bin/sh -c 'python consumer/vote_consumer.py'"                                                                   32 minutes ago      Up 32 minutes                                                                                                                  just_metric_consumer_vote
1f1a3add81ef3631beafd84c9cb94414a4ec28da0e615e168854aa8564150f50   just_teacher_consumer                   "/bin/sh -c 'python consumer/vote_news_consumer.py'"                                                              32 minutes ago      Up 32 minutes                                                                                                                  just_teacher_consumer
001e86c665dd3b658cce34a8940c4c251348e8e1058f381e944856d6da740f35   just_teacher                            "/bin/sh -c 'python main.py'"                                                                                     32 minutes ago      Up 32 minutes               0.0.0.0:5002->5002/tcp                                                                             just_teacher
844bb1c54f9d463e24d9774695f38b06a4c6abbd0318ee0c3e53760523ea9d26   just_scheduler_feed                     "/bin/sh -c 'python SchedulerFeed.py'"                                                                            32 minutes ago      Up 32 minutes                                                                                                                  just_scheduler_feed
34221f4300a3442e8f2c2a769d3b22779b0cbb1dc0b9477b396037f01aff5029   just_scheduler_social                   "/bin/sh -c 'python SchedulerSocial.py'"                                                                          32 minutes ago      Up 32 minutes                                                                                                                  just_scheduler_social
aa56b65738ff5776ceb4f7620f8a7970d9cadddeb833957960896870493df67e   just_social_consumer                    "/bin/sh -c 'python consumer/social_consumer.py'"                                                                 32 minutes ago      Up 32 minutes                                                                                                                  just_social_consumer
a5eac49ca5cece68e907f152d9f2ab7ac75166efe982bd5467912347bd54b34d   just_scheduler_objects                  "/bin/sh -c 'python SchedulerObjects.py'"                                                                         32 minutes ago      Up 32 minutes                                                                                                                  just_scheduler_object
6460985f0d5d917e928ba14bc6a0a83c9cd7bc4d46da8605aaf9deb26a472e32   just_social                             "/bin/sh -c 'python main.py'"                                                                                     32 minutes ago      Up 32 minutes               0.0.0.0:6789->6789/tcp                                                                             just_social
5e4c9beaf91f491f5cc9d72a396a2f65227f1a57fb24bd2923850be6814b2c64   just_server                             "crossbar start --cbdir /mynode/.crossbar"                                                                        32 minutes ago      Up 32 minutes               0.0.0.0:8050->8050/tcp, 0.0.0.0:8060->8060/tcp, 0.0.0.0:8087->8087/tcp, 0.0.0.0:28050->28050/tcp   just_server

1 个答案:

答案 0 :(得分:0)

您如何检查端口是否暴露?您是否尝试从容器内部运行telnet到这些端口?