As we all know, Docker run can specify port mappings, but once the container is generated, no command can be modified directly. Typically, the indirect approach is to save the image, create a new container, and specify a new port mapping at the time of creation.
Is there any way to modify the existing container without saving the image? Yes. Found the answer on the StackOverflow, the original post is as follows
Https://stackoverflow.com/questions/19335444/how-do-i-assign-a-port-mapping-to-an-existing-docker-container
My operation steps are:
1) Stop container
2) Stop Docker service (Systemctl stop Docker)
3) Modify the port in the Hostconfig.json file of this container (the original post has been mentioned, if the Config.v2.json inside also recorded the port, also want to modify)
4) Stop Docker service (Systemctl start Docker)
5) Start the container