Reputation: 9048
I am running 2 Docker containers of a same application without binding to any port, but still getting port is already being used for the second container. Not sure why is this happening as I am not exposing the port.
Running the below command twice with different name.
docker -H unix:///var/run/docker.sock run
--cpu-shares 512
--memory 536870912
-e ARG1=Test
-v /dev/urandom:/dev/random:ro
-v /tmp/mesos/slaves/f1cb5bcd-0590-40f0-91d6-47fdf0315b19-S1/docker/links/15d651e2-51e8-4c6b-b304-4f7faf5e260b:/mnt/mesos/sandbox
--net host
--name test
docker.hub.com/test:latest
Upvotes: 0
Views: 144
Reputation: 311978
Not sure why is this happening as I am not exposing the port.
You are running with --net host
. You are effectively exposing all the ports: that is, the process is running the host's network environment, rather than in an isolated container environment.
If anything else is binding to the ports your containerized application is using (or if you are publishing those ports from another container), you're going to run into this error.
Upvotes: 4