Docker Community Forums

Share and learn in the Docker community.

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

dockerhub
build
docker

(Abhilasha) #1

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 8777:8777. 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.


(slamp) #2

Check with netstat if you see the port on the host


(Abhilasha) #3

I did netstat and I don’t see any port associated with that service when I use “–net=host” in docker run command but I see ports when I don’t use --net=host


(slamp) #4

with --net you don’t need to do -p
docker run -d --net=host ceilometer:1.x

netstat -an | grep 8777 should display it