Skip to content

Instantly share code, notes, and snippets.

@gonzaloplaza
Last active January 6, 2026 07:37
Show Gist options
  • Select an option

  • Save gonzaloplaza/ff79d0593085ed14b3a5c1ba2f8f7afa to your computer and use it in GitHub Desktop.

Select an option

Save gonzaloplaza/ff79d0593085ed14b3a5c1ba2f8f7afa to your computer and use it in GitHub Desktop.
Script to auto install Docker (last version) into AWS EC2/Ubuntu instance at launch time: User Data
#!/bin/bash
# Install docker
apt-get update
apt-get install -y cloud-utils apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update
apt-get install -y docker-ce
usermod -aG docker ubuntu
# Install docker-compose
curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
@jademanta
Copy link
Copy Markdown

Used today for Ubuntu 22 and it worked perfectly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment