Skip to content

Instantly share code, notes, and snippets.

@neutralvibes
Created May 25, 2022 10:53
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 neutralvibes/f8163d7fe34da05aee4325d4dd7e7681 to your computer and use it in GitHub Desktop.
Save neutralvibes/f8163d7fe34da05aee4325d4dd7e7681 to your computer and use it in GitHub Desktop.
Moving docker location

Moving docker location

Moving docker files to a different partition or physical drive can be advantageous in certain senarios.

Stop docker

sudo systemctl stop docker.service
sudo systemctl stop docker.socket

Update docker service file

Here we will edit the docker service and add the -g to specify the new location.

Edit the file

sudo -e /lib/systemd/system/docker.service

Change the line begining with ExecStart to use the new location. Your line may contain other flags that you probably should still include.

ExecStart=/usr/bin/dockerd -g /new_path/docker -H fd:// [any other flags there may be]

Create the new location if if doesn't already exist

sudo mkdir -p /new_path/docker

Copy the data from /var/lib/docker to the new location

sudo rsync -aqxP /var/lib/docker/ /new_path/docker

Restart docker

sudo systemctl daemon-reload
sudo systemctl start docker

Docker should now spin up. I needed to restart all the containers I had running regardless of their restart policy.

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