Reputation: 107
I was having docker containers running in UBUNTU16.04 LTS machine but unfortunately, HDD crashed and I lost some of the data in bad sectors. but I backed up almost 90% data successfully.
I want to copy all the containers from backup to newly installed UBUNTU18.04 LTS
I tried to chroot in the home of the backup but I am not able to start Docker demon running in it
root@a-Lenovo-IdeaPad-Z510:~# chroot /home/a/Documents/Mangesh/backup_root/
root@a-Lenovo-IdeaPad-Z510:/# docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
root@a-Lenovo-IdeaPad-Z510:/# service docker status
* Docker is not running
root@a-Lenovo-IdeaPad-Z510:/# service docker start
* Starting Docker: docker [ OK ]
root@a-Lenovo-IdeaPad-Z510:/# service docker status
* Docker is not running
is it possible to copy docker container file to newly installed docker directories to get a container running
Old OS - UBUNTU16.04 LTS
NEW OS - UBUNTU18.04 LTS
Upvotes: 1
Views: 223
Reputation: 107
Hey I found an answer there is a way to copy the docker container from one os to another without using Docker demon
Docker stores all the containers in the following directory
/var/lib/docker
On Machine from where you want to copy the containers
so copy the /var/lib/docker folder with root permission if you are coping it through removable media
sudo cp -r /var/lib/docker /media/username/removable_media
On Machine to where you want to copy the containers
Connect removable media to this machine
Stop the docker demon
sudo service docker stop
If there is already docker folder in /var/lib/ directory(it will be there in most cases) take a backup of docker folder in same folder
sudo mv /var/lib/docker /var/lib/docker_backup
copy docker folder one which is there in removable media to /var/lib/
sudo mv /media/username/removable_media/docker /var/lib/docker
now start/restart docker daemon
sudo service docker restart
As docker will have to update docker daemon will take a minute or two to start once restarted you can check all containers are available again using
sudo docker ps -a
Upvotes: 1