Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move images of docker in aufs directory to overlay2?

Tags:

linux

docker

I update my kernel of Debian from 3.x to 4.x.
Docker storage become overlay2.

ls /var/lib/docker/ 
containers  image  network  overlay2  plugins  swarm  tmp  trust  volumes

old directory structure is

aufs  containers  graph  image  init  linkgraph.db  network  plugins  repositories-aufs  swarm  tmp  tmp-old  trust  volumes

My images is in aufs directory, I can not start docker service with old directory. how can I move my images to overlay2?

like image 812
Sword Avatar asked Jun 25 '17 10:06

Sword


People also ask

Where is Docker overlay2?

After downloading a five-layer image using docker pull ubuntu , you can see six directories under /var/lib/docker/overlay2 .

What is docker driver overlay2?

overlay2. overlay2 is the preferred storage driver for all currently supported Linux distributions, and requires no extra configuration. fuse-overlayfs. fuse-overlayfs is preferred only for running Rootless Docker on a host that does not provide support for rootless overlay2 .


1 Answers

  1. Identify the images to save and restore after migrating from aufs to overlayfs2.

  2. Export all the images to be migrated to overlayfs into one archive - this is faster and efficient

    sudo docker save $IMAGES -o /data/save.tar

    Here IMAGES is a variable containing the image names

  3. Create /etc/docker/daemon.json with following contents:

    {
      "storage-driver": "overlay2"
    }
    

    [ Refer to https://stackoverflow.com/questions/42245288/add-new-element-to-existing-json-array-with-jq/57537190#57537190 for updating it using jq ]

  4. Take the backup of the directory where docker images are stored and delete the directory

    mv /var/lib/docker/images /var/lib/docker.aufs.images

  5. systemctl daemon-reload

  6. systemctl restart docker

  7. docker load < save.tar

like image 141
pr-pal Avatar answered Sep 22 '22 14:09

pr-pal