Skip to content

Instantly share code, notes, and snippets.

@omersiar
Last active August 9, 2021 09:04
Show Gist options
  • Save omersiar/2356eed23c5d7029c25e667afc1b42d4 to your computer and use it in GitHub Desktop.
Save omersiar/2356eed23c5d7029c25e667afc1b42d4 to your computer and use it in GitHub Desktop.
Change docker's default data directory
# Make sure that we have rsync installed
yum install -y rsync
# Make a copy of original unit file
cp /lib/systemd/system/docker.service /lib/systemd/system/docker.service.orig
# Add data directory string
sed -i 's/\(containerd.sock\)/\1 -g \/opt\/lib\/docker/' /lib/systemd/system/docker.service
# Test files
diff /lib/systemd/system/docker.service /lib/systemd/system/docker.service.orig
# Stop docker service
systemctl stop docker
# Do systemcd daemon-reload as we changed docker.service file
systemctl daemon-reload
# rsync existing docker data to our new location
rsync -aqxP /var/lib/docker/ /opt/lib/docker/
# Start docker service
systemctl start docker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment