View previous topic :: View next topic |
Author |
Message |
davidshen84 Guru
Joined: 09 Aug 2008 Posts: 314
|
Posted: Sun Oct 21, 2018 10:29 am Post subject: 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.
Code: | 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 works once.
Thanks,
D. _________________ David Shen |
|
Back to top |
|
|
davidshen84 Guru
Joined: 09 Aug 2008 Posts: 314
|
Posted: Tue Oct 23, 2018 7:41 am Post subject: |
|
|
Nobody uses docker on Gentoo, or I posted in the wrong section? _________________ David Shen |
|
Back to top |
|
|
forrestfunk81 Guru
Joined: 07 Feb 2006 Posts: 565 Location: münchen.de
|
Posted: Mon Oct 29, 2018 4:06 pm Post subject: |
|
|
I stumbled upon the same problem some time ago. But usually I declare the exposed ports within a Dockerfile and build the container manually. Changing the ports works with this approach. _________________ # cd /pub/
# more beer |
|
Back to top |
|
|
guitou Guru
Joined: 02 Oct 2003 Posts: 534 Location: France
|
Posted: Wed Oct 31, 2018 12:42 pm Post subject: |
|
|
Hello.
I might be completely wrong, but I suppose running the container sets up a "network", while stopping the container does not remove this same network, thus leaving port 80 busy (mapping to an obsolete container).
EDIT: If I am not wrong, then maybe simply running the following command might help:
Code: | docker network prune |
++
Gi) |
|
Back to top |
|
|
|