Created
February 4, 2024 12:40
-
-
Save dazeb/ced7bddd50f842ad53b53764196dbbb3 to your computer and use it in GitHub Desktop.
Docker, Docker Compose, Dockge & Portainer 4in1 BASH
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 | |
# Check for curl and wget | |
if ! command -v curl &> /dev/null; then | |
echo "curl could not be found, please install curl." | |
exit 1 | |
fi | |
if ! command -v wget &> /dev/null; then | |
echo "wget could not be found, please install wget." | |
exit 1 | |
fi | |
# Install Docker | |
echo "Installing Docker..." | |
sh <(curl -sSL https://get.docker.com) | |
if [ $? -ne 0 ]; then | |
echo "Docker installation failed." | |
exit 1 | |
fi | |
# Optional: Add the current user to the docker group | |
sudo usermod -aG docker $USER | |
# Install Docker Compose | |
echo "Installing Docker Compose..." | |
LATEST=$(curl -sL https://api.github.com/repos/docker/compose/releases/latest | grep '"tag_name":' | cut -d'"' -f4) | |
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} | |
mkdir -p $DOCKER_CONFIG/cli-plugins | |
curl -sSL https://github.com/docker/compose/releases/download/$LATEST/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose | |
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose | |
docker compose version | |
if [ $? -ne 0 ]; then | |
echo "Docker Compose installation failed." | |
exit 1 | |
fi | |
# Add Dockge | |
echo "Adding Dockge..." | |
mkdir -p /opt/{dockge,stacks} | |
wget -q -O /opt/dockge/compose.yaml https://raw.githubusercontent.com/louislam/dockge/master/compose.yaml | |
cd /opt/dockge | |
docker compose up -d | |
if [ $? -ne 0 ]; then | |
echo "Dockge installation failed." | |
exit 1 | |
fi | |
# Add Portainer | |
echo "Adding Portainer..." | |
docker volume create portainer_data | |
docker run -d \ | |
-p 8000:8000 \ | |
-p 9443:9443 \ | |
--name=portainer \ | |
--restart=always \ | |
-v /var/run/docker.sock:/var/run/docker.sock \ | |
-v portainer_data:/data \ | |
portainer/portainer-ce:latest | |
if [ $? -ne 0 ]; then | |
echo "Portainer installation failed." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment