Docker Community Forums

Share and learn in the Docker community.

Container port mapping only work once per restart


(Xi Shen) #1

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.