What is the easiest way to export a Docker container to VM What is the easiest way to export a Docker container to VM docker docker

What is the easiest way to export a Docker container to VM


With the command docker commit you can create a image from a container, then put the image on your resgistry, and in Production use the command docker run to run the container with the new image. The new image will have all data inside.

Example:

  1. On dev, get the id of your by docker ps

    docker psCONTAINER ID      IMAGE        COMMAND            CREATED        STATUS              PORTS                   NAMESba8a9e9ecd1b      Hbase/ex1    "/sbin/my_init"    12 days ago    Up About a minute   0.0.0.0:80, 0.0.0.0:80  dev-c
  2. Create a new image from the container

    docker commit ba8a9e9ecd1b repo/new-image
  3. Push you new image to registry

    docker push repo/new-image
  4. Run the container in Production

    docker run -itd repo/new-image