方法1

  1. stop running container
    
    
    1
    docker stop test01
  2. commit the container
    
    
    1
    docker commit test01 test02

    NOTE: The above, 

    1
    test02

     is a new image that I’m constructing from the 

    1
    test01

     container.

  3. re-run from the commited image
    
    
    1
    docker run -p 8080:8080 -td test02

方法2

  1. stop running container
  2. find docker container in the file system
    1. In Linux, it’s most likely here
      
      
      1
      /var/lib/docker/containers/
    2. In Mac, follow this document
  3. Update “PortBindings” in hostconfig.json, and “ExposedPorts”, “Ports” in config.v2.json or config.json
  4. Restart docker daemon
    
    
    1
    /etc/init.d/docker restart
  5. start your container