Container port mapping only work once per restart

Hi,

My system info.

  • Gentoo 64 bit
  • Docker version 18.03.1-ce, build 9ee9f40

After I installed and started the docker service, I was able to launch the nginx container and access the welcome page.

docker run --rm -p 80:80 nginx:latest

But after I killed the container, and re-launch it with the same command, the container can start, but I cannot access the welcome page at http://localhost:80. I also found the browser did not say the connection was refused, instead, it just waits forever.

If I restart the docker service, I was able to create a new nginx container and access the welcome page. But, if I kill the container, the same issue re-occurs.

It feels like the port mapping function only work once.

Thanks,
D.

1 Like

Hi,
I’ve got the same Problem and no idea how to fix it. Only the first docker run really exposes the ports as I want it but after stoping/removing the container the second time running the SAME run command sill works an all looks fine but there is no connection to the docker. running lsof -i -P even shows that docker is using the ports but its still not working.
If I apt purge docker.io and reinstall it, it again works once but then stops working again.
I’ve created a big question with way more details at Server Fault: Unable to forwart ports on any docker - Server Fault

I realy hope someone can help!

Docker itself, neither provides a gentoo package, nor does it provide the docker.io package. Package maintainers typicaly modify their packages to align with the os or package managers philosophy. Thus, I would recommend to raise an issue to the maintainer of the docker re-distribution, or post the issue in the forum of the os/package maintainer.

On OS`es based on Debian, Ubuntu, CentOS, it is usualy less headache / more reliable to use the packages from docker’s official repositories.