Ways to modify Docker container port mappings

Source: Internet
Author: User
Tags json docker run

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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.