Backup and Restore Upgrade a Container - ganeshahv/Contrail_SRE GitHub Wiki
- Create a container as below:
 
docker run -d --restart=unless-stopped -p 80:80 -p 443:443 -v /opt/rancher:/var/lib/rancher rancher/rancher:v2.4.1
- Stop the container currently running
 
docker stop <CONTAINER_NAME>
- Create a data container from the container that was just stopped.
 
docker create --volumes-from <CONTAINER_NAME> --name container-data <CONTAINER_IMAGE>
- From the data container that was just created, create a backup tarball which will serve as a rollback point if something goes wrong during upgrade.
 
docker run --volumes-from container-data -v $PWD:/backup busybox tar zcvf /backup/data-backup-<VERSION>-<DATE>.tar.gz /var/lib/docker
- Enter the 
lscommand to confirm that the backup tarball was created. 
- Pull the image of the Rancher version that you want to upgrade to.
 
docker pull <CONTAINER_IMAGE>
- Start a new container using the data from the data container. Remember to pass in all the environment variables that you had used when you started the original container.
 
docker run -d --volumes-from container-data --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher:latest
- Stop the old container
 
docker rm <CONTAINER_NAME>