54 lines
1.5 KiB
Bash
54 lines
1.5 KiB
Bash
#!/bin/bash
|
|
# Docker installation script for LXC container in Proxmox
|
|
|
|
# Exit on any error
|
|
set -e
|
|
|
|
echo "Starting Docker installation for LXC container..."
|
|
|
|
# Fix DNS if needed
|
|
echo "Checking and fixing DNS configuration..."
|
|
if ! grep -q "nameserver" /etc/resolv.conf; then
|
|
echo "DNS configuration missing or empty, adding Google DNS servers..."
|
|
echo "nameserver 8.8.8.8
|
|
nameserver 8.8.4.4" > /etc/resolv.conf
|
|
echo "DNS configuration fixed."
|
|
fi
|
|
|
|
# Install basic tools first
|
|
echo "Installing basic tools..."
|
|
apt update
|
|
apt install -y curl wget apt-transport-https ca-certificates gnupg lsb-release
|
|
|
|
# Update the system
|
|
echo "Updating system packages..."
|
|
apt update && apt upgrade -y
|
|
|
|
# Download the Docker installation script
|
|
echo "Downloading official Docker installation script..."
|
|
curl -fsSL https://get.docker.com -o get-docker.sh
|
|
|
|
# Make it executable
|
|
chmod +x get-docker.sh
|
|
|
|
# Run the installation script
|
|
echo "Running Docker installation script..."
|
|
sh ./get-docker.sh
|
|
|
|
# Install Docker Compose
|
|
echo "Installing Docker Compose..."
|
|
curl -L "https://github.com/docker/compose/releases/download/v2.20.3/docker-compose-linux-$(uname -m)" -o /usr/local/bin/docker-compose
|
|
chmod +x /usr/local/bin/docker-compose
|
|
|
|
# Enable Docker to start on boot
|
|
echo "Enabling Docker to start on boot..."
|
|
systemctl enable docker
|
|
|
|
# Verify installations
|
|
echo "Verifying installations..."
|
|
docker --version
|
|
docker-compose --version
|
|
|
|
echo "Docker installation complete!"
|
|
echo "You can now use Docker and Docker Compose in your LXC container."
|