Last active
September 27, 2024 12:57
-
-
Save DamichiXL/514e10a78ad19286cd9289ff228d07c5 to your computer and use it in GitHub Desktop.
Update docker configuration - mount to custom mountpoint
This file contains hidden or 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 | |
echo "Stopping docker services" | |
systemctl stop docker.service | |
systemctl stop docker.socket | |
echo "Stopped" | |
DATA_ROOT="/home/docker" | |
FILE="/lib/systemd/system/docker.service" | |
SEARCH_LINE="^ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock" | |
REPLACE_LINE="ExecStart=/usr/bin/dockerd -H fd:// --data-root $DATA_ROOT --containerd=/run/containerd/containerd.sock" | |
# Check if the file exists | |
if [[ -f "$FILE" ]]; then | |
# Use sed to replace the line | |
sed -i "s|$SEARCH_LINE|$REPLACE_LINE|" "$FILE" | |
echo "Updated ExecStart in $FILE" | |
else | |
echo "File $FILE does not exist." | |
fi | |
echo "Removing files from /var/lib/docker" | |
rm -rf /var/lib/docker | |
echo "Reloading daemon" | |
systemctl daemon-reload | |
echo "Start docker services" | |
systemctl start docker | |
echo "--Finished--" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment