Docker container doesn't expose ports when --net=host is mentioned in the docker run command

后端 未结 2 1264
野性不改
野性不改 2020-12-09 15:27

I have a CentOS docker container on a CentOS docker host. When I use this command to run the docker image docker run -d --net=host -p 8777:8777 ceilometer:1.x t

2条回答
  •  难免孤独
    2020-12-09 15:56

    The docker version is 1.10.1. I want the docker container to have same ip as the host with ports exposed.

    When you use --net=host it tells the container to use the hosts networking stack. So you can't expose ports to the host, because it is the host (as far as the network stack is concerned).

    docker inspect might not show the expose ports, but if you have an application listening on a port, it will be available as if it were running on the host.

提交回复
热议问题