Skip to content

Instantly share code, notes, and snippets.

@ohjho
Created January 19, 2021 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohjho/f3afe46b7d9d5ed749d5d0d5ef3b5397 to your computer and use it in GitHub Desktop.
Save ohjho/f3afe46b7d9d5ed749d5d0d5ef3b5397 to your computer and use it in GitHub Desktop.
How to Change Docker's Image Installation Directory

To remove unused images, docker image prune -a, and containers , docker container prune

1. Stop Docker

sudo service docker stop then make sure docker is stop with ps aux| grep docker

2. Backup current docker directory

sudo cp -r /var/lib/docker /your/storage/dir

3. Update Docker Configs per this post

Ubuntu/Debian: edit your /etc/default/docker file with the -g option: DOCKER_OPTS="-dns 8.8.8.8 -dns 8.8.4.4 -g /mnt"

Fedora/Centos: edit /etc/sysconfig/docker, and add the -g option in the other_args variable: ex. other_args="-g /your/storage/dir". If there’s more than one option, make sure you enclose them in " ". After a restart, (service docker restart) Docker should use the new directory.

4. Restart Docker

sudo service docker restart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment