What happens to published ports when the container restarts?

BeginnerConceptNetworking
Answer

Fixed host ports (-p 8080:80) are rebound to the new container IP automatically since iptables rules are rewritten. With -P or -p 80 (random host port) the host port may change; query with docker port web.

All Docker questions Roadmap: Docker & containers

More on Networking