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:

  • All my docker containers have the error “Too many open files”
  • How to run Caddy from Docker container? (443 bind: permission denied)
  • (psycopg2.OperationalError) could not connect to server: Connection refused Is the server
  • Manage multiple nginx containers on the same host with Docker Swarm
  • How to set the workdir of a container launched by Kubernetes
  • Jenkins shell script add Unix user to group
  • 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?

  • Setting up a remote private Docker registry
  • Couchbase XDCR in a Docker container
  • Vagrant docker provisioning with env variables and network
  • How to change express.js microservice application for ecs auto scaling
  • Dockerizing Spring Applicaiton
  • How does it possible that Ubuntu image has only ~100MB?
  • 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.