Skip to content

Instantly share code, notes, and snippets.

@diegoquintanav
Last active May 20, 2023 12:01
Show Gist options
  • Save diegoquintanav/700cb907463665a228a37d4112a82437 to your computer and use it in GitHub Desktop.
Save diegoquintanav/700cb907463665a228a37d4112a82437 to your computer and use it in GitHub Desktop.
change mount point for docker containers

I want docker to stop using my root partition for storing docker containers, and use a different partition instead, e.g. /home

These steps worked for me:

  1. Stop all containers sudo docker stop $(docker ps -a -q)
  2. Stop docker sudo service docker stop
  3. Copy docker directory cp -r /var/lib/docker/* /home/docker/
  4. Unmount all old docker overlays umount -f /var/lib/docker/overlay/ and umount -f /var/lib/docker/containers/*/mounts/shm
  5. Add or update /etc/docker/daemon.json with
{
  "graph": "/home/docker/"
  }
  1. Start docker with sudo service docker start
  2. Remove old /var/lib/docker/
@diegoquintanav
Copy link
Author

update: graph is outdated, use data-root

{
  "data-root": "/new/path/to/docker-data"
}

and then

sudo systemctl daemon-reload
sudo systemctl restart docker

references

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