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:

  • Does putting ARG at top of Dockerfile prevent layer re-use?
  • How to rename a Bluemix namespace (container registry)?
  • Xdebug on Docker doesn't work with PhpStorm
  • How to make docker only use a eth1 interface to communicate with other hosts?
  • Unable to build docker from root
  • Consul running on Docker HTTP health check returns “connection reset by peer”
  • 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?

  • Gitlab docker not working if external_url is set
  • Permissions issue with shared host drive mounted to two docker containers
  • Unable to back up persistent storage container for docker MariaDB container
  • docker-machine amazon-ec2 fail during init
  • Trying to setup lamp and wordpress on kitematic for docker
  • Opening a (Bluemix) container to all incoming connection
  • 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.