How to get the mapped port on host from a docker container?

前端 未结 3 1822
南方客
南方客 2021-02-02 15:59

I want to run a task in some docker containers on different hosts. And I have written a manager app to manage the containers(start task, stop task, get status, etc...) . Once a

3条回答
  •  粉色の甜心
    2021-02-02 16:29

    You can also you docker port container_id

    The doc

    https://docs.docker.com/reference/commandline/port/

    examples from the doc

    $ docker port test
    7890/tcp -> 0.0.0.0:4321
    9876/tcp -> 0.0.0.0:1234
    $ docker port test 7890/tcp
    0.0.0.0:4321
    $ docker port test 7890/udp
    2014/06/24 11:53:36 Error: No public port '7890/udp' published for test
    $ docker port test 7890
    0.0.0.0:4321
    

提交回复
热议问题