How to move Images and Containers to new Server with historical data

image :

docker save -o /root/bkp1/docker_image_bkp ccn/ccn-server:1.0.4

Container:

  • docker unit test setup
  • Docker: Output shown at http://192.168.99.100:8000/ instead of http://0.0.0.0:8000/
  • I can't run rails console with Docker and Passenger/nginx image
  • Error cannot find -lz building MariaDB on a debian based container
  • Cleaning up after multiple docker inserts
  • Docker on Windows 10 does it work? [closed]
  • docker export cef0dff04e70 > /root/bkp1/container.tar
    

    In new server :

    docker load -i /root/pmmbkp1/docker_image_bkp
    
    cat /root/bkp1/container.tar | docker import - ccdata
    

    And I created and started it. But I am not able find the old data in the new server. How do I move the historical data along with the containers?

  • JVM memory settings in docker container in AWS beanstalk
  • CoreOS Fleet could not get container
  • Add a potentially large amount of metadata to a docker image
  • Custom mesos executor for docker in chronos
  • How to expose audio from Docker container to a Mac?
  • How to setup GUI for private docker registry?
  • One Solution collect form web for “How to move Images and Containers to new Server with historical data”

    Currently (Sep 2016), NONE of docker save or docker export or even docker commit could produce a tar file that includes any data contained in volumes mounted inside the container.

    In a short, if you want move volume data from one server to another, the best way is using shared file system to store your docker container’s data. Please check the Mount a shared-storage volume as a data volume document.

    Once you have a shared storage for your Docker cluster, you could stop your old container in the original server, then use the same configurations to start a new container in another server. Both of the old container and the new container should mount the same volume that existing in the shared storage system.

    Data Persistent is still a problem in Docker’s orchestration system. But another orchestration tool, Kubernetes 1.4, now support Persistent Volumes.

    EDIT:

    If your container is already running and you want to move it around, you may try to do the following steps:

    1. Save your original container to a image with docker save or docker commit. Then load the saved image to the new server.

    2. Check the mount points of original container, then find the local volume files with your mount points configuration. For example, with docker inspect, you can find something similar to this:

      “Mounts”: [

      {
          "Name": "95d7a2419c62242149562d5098edcc7578754ae2f3c35a45c4d690f3c340905a",
          "Source": "/var/lib/docker/volumes/95d7a2419c62242149562d5098edcc7578754ae2f3c35a45c4d690f3c340905a/_data",
          "Destination": "/var/lib/mysql",
          "Driver": "local",
          "Mode": "",
          "RW": true,
          "Propagation": ""
      }
      

      ],

    Here you can see the mount point is "/var/lib/docker/volumes/95d7a2419c62242149562d5098edcc7578754ae2f3c35a45c4d690f3c340905a/_data"

    1. Copy your local volume file to the new server.

    2. Start a new container in the new server, where new container should mount the copy of original local volume file to it. You can use docker run command’s -v parameter to achieve it.

    3. You may need consider to use the same configuration to start new container in the new server. docker inspect command can help you find out the configuration of a container, as well as the mount point configuration.

    Above solution might looks complicated and ugly, but there is no other way to move container easily unless you are using shared-storage.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.