allow modification of docker root directory

This commit is contained in:
scriptos 2024-02-22 22:49:50 +01:00
parent 0dc737ac2f
commit 5fc736cdda

View File

@ -1,16 +1,18 @@
#!/bin/bash #!/bin/bash
# Script Name: docker-installer.v3.sh # Script Name: docker-installer.v3.sh
# Beschreibung: Docker & Docker-Compose installieren (Für Ubuntu) # Beschreibung: Docker & Docker-Compose installieren und Docker-Root-Verzeichnis ändern (Für Ubuntu)
# Aufruf: bash ./docker-installer.v3.sh # Aufruf: bash ./docker-installer.v3.sh
# Autor: Patrick Asmus # Autor: Patrick Asmus
# Web: https://www.media-techport.de # Web: https://www.media-techport.de
# Git-Reposit.: https://git.media-techport.de/scriptos/docker-installer # Git-Reposit.: https://git.media-techport.de/scriptos/docker-installer
# Version: 3.0.1 # Version: 3.1
# Datum: 11.06.2023 # Datum: 22.02.2024
##################################################### #####################################################
# Variablen # Variablen
USER="root" USER="root"
DOCKER_ROOT_DIR="/docker"
COMPOSE_DIR="/compose"
# Docker installieren # Docker installieren
sudo apt update sudo apt update
@ -19,18 +21,24 @@ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io sudo apt install -y docker-ce docker-ce-cli containerd.io
# Docker-Root-Verzeichnis ändern
sudo mkdir -p $DOCKER_ROOT_DIR
sudo systemctl stop docker
echo "{\"data-root\": \"$DOCKER_ROOT_DIR\"}" | sudo tee /etc/docker/daemon.json
sudo systemctl start docker sudo systemctl start docker
sudo usermod -aG docker $USER sudo usermod -aG docker $USER
# Erstelle Compose-Verzeichnis
mkdir $COMPOSE_DIR
# Docker-compose installieren # Docker-compose installieren
sudo apt install -y curl sudo apt install -y curl
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose
# Optional: Ordner erstellen und Plugin für Oh my ZSH aktivieren # Optional: Plugin für Oh my ZSH aktivieren
mkdir /docker echo "OhMyZSH Plugin für Docker hinzufügen"
touch /docker/docker-compose.yaml
echo OhMyZSH Plugin für Docker hinzufügen
sudo sed -i 's/plugins=(git)/plugins=(git docker)/g' /root/.zshrc sudo sed -i 's/plugins=(git)/plugins=(git docker)/g' /root/.zshrc
# Überprüfen der Installation # Überprüfen der Installation