1

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

2
  • May this post can help you? Commented Jul 18, 2018 at 11:33
  • juanlumn thank you for the reply but my older ubuntu installation is damaged and as you can see in error I am unable to run docker demon so I cannot run docker save command Commented Jul 18, 2018 at 16:32

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.