Skip to content

Instantly share code, notes, and snippets.

@peteygao
Last active February 17, 2024 05:03
Show Gist options
  • Save peteygao/a26d63e2089dda4644c4d1630d358ef9 to your computer and use it in GitHub Desktop.
Save peteygao/a26d63e2089dda4644c4d1630d358ef9 to your computer and use it in GitHub Desktop.
Auto-Install Docker and Docker Compose on AWS Lightsail running Ubuntu 20.04
# Create a 1GiB Swap File
# Lightsail ubuntu image doesn't boot with swap.
# If you run out of RAM, the system hangs OOM.
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
# Perform the actual Docker related installation
sudo apt update
sudo apt-get install -y apt-transport-https ca-certificates software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt-get install -y docker-ce
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo groupadd docker
sudo usermod -aG docker ubuntu
sudo systemctl enable docker
sudo systemctl start docker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment