dev-resources.site
for different kinds of informations.
Short: User Data file for Ubuntu based AWS ec2 instance with docker and docker compose.
Published at
12/23/2024
Categories
ubuntu
docker
ec2
Author
Rodrigo Burgos
#!/bin/bash
# Update the system
sudo apt-get update -y
sudo apt-get upgrade -y
# Install Git
sudo apt-get install -y git
# Install Docker
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) 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-get update -y
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
# Add the 'ubuntu' and 'ssm-user' to the Docker group
sudo usermod -aG docker ubuntu
sudo usermod -aG docker ssm-user
id ubuntu ssm-user
sudo newgrp docker
# Enable and start Docker
sudo systemctl enable docker.service
sudo systemctl start docker.service
# Install Docker Compose v2
sudo mkdir -p /usr/local/lib/docker/cli-plugins
sudo curl -SL https://github.com/docker/compose/releases/download/v2.23.3/docker-compose-linux-x86_64 -o /usr/local/lib/docker/cli-plugins/docker-compose
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
# Add swap space
sudo dd if=/dev/zero of=/swapfile bs=128M count=32
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo "/swapfile swap swap defaults 0 0" | sudo tee -a /etc/fstab
Gist link:
https://gist.github.com/burgossrodrigo/790406f04f6bd38d4baee0364fce2f04
Articles
12 articles in total
How to work with CAR files with NestJS
read article
Short: User Data file for Ubuntu based AWS ec2 instance with docker and docker compose.
currently reading
Solving the Empty Path Issue in Go Lambda Functions with API Gateway HTTP API
read article
Short: How to use VSCode on WSL2
read article
Lessons Learned: Migrating ECS + RDS Projects with Terraform (and Avoiding Costly Mistakes)
read article
Building a Simple Token Quote API with Go, Gin, and 1inch
read article
How to Deploy MongoDB on Google Kubernetes Engine (GKE)
read article
Sending GitHub Secrets to Docker Apps on VMs Using adnanh/webhooks
read article
Asserting Integrity in Ethereum Data Extraction with Go through tests
read article
Extracting the Sender from a Transaction with Go-Ethereum
read article
Extracting and Converting Transaction Input Data in Go
read article
Running Cron Jobs with Go on AWS Lambda
read article
Featured ones: