roman
roman

Reputation: 670

Docker produces 'port already allocated' when IP address is specified in port definition

I've run into a strange issue with docker.

sudo docker run -d -p 54.201.110.30:80:80 image

results in

2015/02/03 23:36:28 Error response from daemon: Cannot start container 86eea21e1a83a115fdf77c87303f94d56dd5ed4f07fb946d8abea85532761f28: port has already been allocated

While

sudo docker run -d -p 80:80 image

works just fine. The port 80 on the host is free (checked with netstat -l).

Any ideas what can be a reason?

Upvotes: 0

Views: 1142

Answers (2)

roman
roman

Reputation: 670

The reason is IP address was not being assigned to the host.

Upvotes: 0

Andy
Andy

Reputation: 17771

I experience similar but occasional "port has already been allocated" issues on Fedora 20.

service docker restart or systemctl restart docker generally fixes intermittent startup problems. I've never experienced this issue on CoreOS and it seems to have gone away with v1.4.

You should also add your user to the docker group instead of using sudo. Don't forget groups are applied at login, so you may have to log out and back in again to see your group updated.

Upvotes: 1

Related Questions