I have a CentOS docker container on CentOS docker host. When I use this command to run the docker image

docker run -d --net=host -p 8777:8777 ceilometer:1.x

the docker container get host's IP but doesn't have ports assigned to it. If I run the same command without "--net=host":

docker run -d -p 8777:8777 ceilometer:1.x

the docker exposes the ports but with different ip. The docker version is 1.10.1. I want the docker container to have same ip as the host with ports exposed. I also have mentioned in the Dockerfile the instruction EXPOSE 8777 but with no use when "--net=host" is mentioned in the docker run command.

1 Answer 1


If you use --net=host the container share(s) the host's network stack and all interfaces from the host will be available to the container, (as per the run reference for docker)

If you already share everything you don't need to explicitly map 8777 to 8777. Actually implementing mapping something would be strange: mapping 1234 to 8777 would make the host listen on 8777 as well? That's why you don't see any ports assigned.

Just leave out the --net=host and try connecting on the host to 8777 it will be bridged to 8777 on the container. Make sure your container is agnostic to the actual IP address it uses. The outside world will only see the hosts IP.

  • I want the docker container to have same IP as the host. This is how the keystone determines the endpoints. If the IP is different, then I need to change the config in each host I deploy the container, a tedious task.
    – arevur
    Feb 23, 2016 at 23:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .