Created
January 1, 2024 21:29
-
-
Save Ujjwal0501/f3bc7c6c929fb5108eed76bfe016ecda to your computer and use it in GitHub Desktop.
Change the default docker cache directory from /var/lib/docker to /home/docker-data
This file contains 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
#!/bin/bash | |
set -e | |
FILE_PATH="/etc/docker/daemon.json" | |
# do not write if daemon.json already exists | |
if [ -e "$FILE_PATH" ]; then | |
echo "File ($FILE_PATH) already present. No changes made" | |
exit 1 | |
fi | |
cat <<EOF > "$FILE_PATH" | |
{ | |
"data-root": "/home/docker-data" | |
} | |
EOF | |
mkdir -p /home/docker-data | |
systemctl restart docker | |
# free disk space | |
rm -rf /var/lib/docker/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment