failed: port is already allocated

24.2k views Asked by At

I use Docker for running Oracle 11g Express on macOS Sierra 10.12.2

https://github.com/wnameless/docker-oracle-xe-11g

This is my error:

Last login: Sat Jan  7 22:42:11 on ttys000
➜  ~ docker run -d -p 49160:22 -p 49161:1521 wnameless/oracle-xe-11g
docker: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
See 'docker run --help'.
➜  ~ docker run -d -p 49160:22 -p 49161:1521 wnameless/oracle-xe-11g
043d8caecbb45d6e2e5999b69a2f760c20d53ff3aa2fad78cb1eb70acb058a1f
docker: Error response from daemon: driver failed programming external connectivity on endpoint serene_lalande (08bb0bd9684c0f92db7b736986bf894d3a57a714324405823496d13e175e7491): Error starting userland proxy: Bind for 0.0.0.0:49161 failed: port is already allocated.
➜  ~ 

I diagnostic:

➜  ~ netstat -anp tcp | grep 49161                                  
tcp4       0      0  192.168.1.2.49161      17.188.166.13.5223     ESTABLISHED
➜  ~

➜  ~ docker --version
Docker version 1.12.5, build 7392c3b

My Dianostic ID: 20EB9506-CC72-4093-8A15-60E05A841ED1

I don't know why. Before that few weeks, it run success. Nearly, I change, release new DHCP IP. How to run Docker instance has Oracle 11g express success?

2

There are 2 answers

1
user2915097 On BEST ANSWER

you can't launch twice

docker run -d -p 49160:22

as this means you want to allocate the port 49160 on the host twice, of course, the second time, you get you error message, try for the second run

docker run -d -p 49161:22

0
Halprin On

You will need to use a different port instead of 49161. Try a port less than 49152.

You have a pre-existing connection between the the port 49161 on your computer and port 5223 on a remote Apple server. That port, therefore, cannot be used for anything else until that connection ceases to exist. Port 5223 is used for Apple's push notifications. As best as I can tell, your computer so happened to use the random port 49161 to connect to Apple's server this time. Previously when that Docker container worked, I would bet port 49161 on your computer was not then used.

Whenever you connect to a remote server, your own computer allocates a random port number for that connection. This time around, your computer allocated 49161 when it connected to Apple's push notifications service. Next time, it could be a completely different number. See https://en.wikipedia.org/wiki/Ephemeral_port