Docker does not have a mechanism for changing published container ports after it starts. When you publish a port, two things happen:
- Docker creates
iptables rules in the nat table, which redirect traffic to the "public" port in the container. - Docker launches a proxy service that listens on this port to process locally generated traffic.
Although you could theoretically manually update the firewall rules to make the service available on the new port, you cannot cancel the Docker proxy and therefore cannot start any new services using this βpublicβ port.
Your best course of action is to simply remove the container and redistribute it, or rely on some kind of external proxy server to handle the redirection, rather than using the Docker port publishing mechanism.
source share