# Docker migrate to overlay2 from aufs script Crazy that this is pretty much forced change without proper transition script Based on https://www.sylvaincoudeville.fr/2019/12/docker-migrer-le-stockage-aufs-vers-overlay2/ NOT WORKING!!!! IF FOLLOWING THE ABOVE.. SOMEHOW THE CONTAINERS DO NOT RE-APPEAR! The only way I found that is somewhat automated is the the docker-compose way.. Which is still not 100% and require manual fixing of stupid errors of the docker-compose tool (mainly things that ere not interpreted right, like dates & userIds that need to manually surrounded by quotes etc) Also I needed to add `network_mode: bridge` to the configs as I did not want a network definition for each container which seems to be the docker-compose default way ## Backup the whole crap before doing heart surgery ``` sudo systemctl stop docker sudo cp -au /var/lib/docker /var/lib/docker.bk sudo systemctl start docker ``` ## Migrate Export all container configs ``` cd ~ mkdir dockercontainers sudo docker container list > dockercontainers/containers.txt cat dockercontainers/containers.txt CIDS=$(docker container list -all | sed '1d' | awk '{print $1}') for c in $CIDS; do mkdir dockercontainers/$c ; docker run --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/red5d/docker-autocompose $c > ~/dockercontainers/$c/docker-compose.yml ; done # or if local (with fixes) for c in $CIDS; do mkdir ~/dockercontainers/$c ; ~/autocompose.py $c > dockercontainers/$c/docker-compose.yml ; done # check if there are no errors in the created files for c in $CIDS; do cd ~/dockercontainers/$c ; echo ======== $c ======= ;docker-compose config ; done #Fix possible errors... ``` Store all images (I think not needed if no persistent references are used) ``` cd ~ mkdir dockersave sudo docker images > dockersave/list.txt cat dockersave/list.txt IDS=$(docker images | sed '1d' | awk '{print $3}') for c in $IDS; do docker save -o dockersave/$c.tar $c; done cat dockersave/list.txt | sed '1d' | grep -v "" | awk '{ print "docker tag "$3" "$1":"$2 }'>> dockersave/tag ``` ## Change driver ``` sudo systemctl stop docker sudo nano /etc/docker/daemon.json ``` if the file is already there, add line `"storage-driver" : "overlay2" ` if the file is empty, you can go with ` echo '{ "storage-driver" : "overlay2" }' > /etc/docker/daemon.json` `sudo systemctl start docker` What also works is edit the file first and than just restart (so no need to stop first) `sudo systemctl restart docker` ## Restore images ``` cd dockersave/ IDS=$(ls *.tar) for c in $IDS; do docker load -i $c; done ``` ## Restore containers `for c in $CIDS; do cd ~/dockercontainers/$c ; docker-compose up -d --no-deps --build ; done`