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.
More on Networking
What network drivers does Docker have?BeginnerHow does the default bridge network work?AdvancedDefault bridge vs user-defined bridge: what is the difference?IntermediateHow does container DNS work?IntermediateHow does `-p 8080:80` work under the hood?AdvancedWhat is the difference between `-p 80:80` and `-p 127.0.0.1:80:80`?Beginner