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.

--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
  • Running the below command twice. => --name test. I would suspect you get a name conflict before you can even get any port conflict. – Zeitounator Jan 28 at 0:21
  • Just changed the name. Updating my question – user1578872 Jan 28 at 0:22


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.

|improve this answer|||||
  • I am not running anything in that host other than the containers. So, --net publishes port that the container is running. – user1578872 Jan 28 at 13:22
  • Not --net by itself, but --net host, which means "run these processes in the host network namespace instead of isolating them". In most cases you're better off not using --net host and instead explicitly publishing specific ports. – larsks Jan 28 at 14:32

Your Answer

