方法1

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

    NOTE: The above, test02 is a new image that I’m constructing from the test01 container.

  3. re-run from the commited image
    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
      /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
    /etc/init.d/docker restart
  5. start your container