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:

  • Running an Oracle XE Docker image on a Redhat Host
  • What is the best practice for Docker CD/CI workflow?
  • cURL from host-to-container works, but from container-to-container does not
  • Where can I find the list of Docker format template variables?
  • Volumes mounting as folders
  • Download size of docker images
  • 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?

  • Using Kubernetes with an Artifactory/Nginx proxy
  • Secure Admin must be enabled to access the DAS remotely - Acess Glassfish Admin Console with Docker
  • Docker:Registry:Unable to pull from someone elses private registry
  • docker .env file reuse declared variables
  • How can I set a static IP address in a Docker container?
  • How to circumvent “Read-only file system” error on Docker version 0.11 or greater when running sysctl -w during an image build?
  • 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.