Last active
November 11, 2020 22:25
-
-
Save pansapiens/a7d2fb930336613a2845a49aa75616a0 to your computer and use it in GitHub Desktop.
Move /var/lib/docker to a new location
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Update - no longer works. You need to also: | |
# edit: /lib/systemd/system/docker.service | |
# then run: sudo systemctl daemon-reload | |
# see, https://medium.com/@ibrahimgunduz34/how-to-change-docker-data-folder-configuration-33d372669056 | |
# | |
# TODO: Fix this to use sed or similar to edit /lib/systemd/system/docker.service | |
## | |
# From: https://forums.docker.com/t/how-do-i-change-the-docker-image-installation-directory/1169 | |
DOCKER_IMAGE_PATH="/mnt/docker" | |
BACKUP_PATH="/mnt" | |
sudo echo 'DOCKER_OPTS="-dns 8.8.8.8 -dns 8.8.4.4 -g ${DOCKER_IMAGE_PATH}"' >>/etc/default/docker && \ | |
sudo service docker stop && \ | |
tar -zcC /var/lib docker >${BACKUP_PATH}/var_lib_docker-backup-$(date +%s).tar.gz && \ | |
sudo mv /var/lib/docker ${DOCKER_IMAGE_PATH} && \ | |
sudo ln -s ${DOCKER_IMAGE_PATH} /var/lib/docker && \ | |
sudo service docker start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like there is a better way using
data-root
in/etc/docker/daemon.json
now: https://www.guguweb.com/2019/02/07/how-to-move-docker-data-directory-to-another-location-on-ubuntu/