Skip to content

Instantly share code, notes, and snippets.

@syntaqx
Last active November 10, 2024 20:04
Show Gist options
  • Save syntaqx/9dd3ff11fb3d48b032c84f3e31af9163 to your computer and use it in GitHub Desktop.
Save syntaqx/9dd3ff11fb3d48b032c84f3e31af9163 to your computer and use it in GitHub Desktop.
cloud init / cloud config to install Docker on Ubuntu
#cloud-config
# Option 1 - Full installation using cURL
package_update: true
package_upgrade: true
groups:
- docker
system_info:
default_user:
groups: [ docker ]
packages:
- apt-transport-https
- ca-certificates
- curl
- gnupg
- lsb-release
- unattended-upgrades
runcmd:
- mkdir -p /etc/apt/keyrings
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
- apt-get update
- apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
- systemctl enable docker
- systemctl start docker
final_message: "The system is finally up, after $UPTIME seconds"
#cloud-config
# Option 2: Simplified, using the default package
package_update: true
package_upgrade: true
groups:
- docker
system_info:
default_user:
groups: [docker]
packages:
- docker.io
- unattended-upgrades
final_message: "The system is finally up, after $UPTIME seconds"
@syntaqx
Copy link
Author

syntaqx commented Sep 15, 2022

Thanks for all the feedback over time, I've updated the script with some latest goodies, and hope that the latest form maps more closely with some of the information regarding the default_user as well as the latest recommended docker installation commands and packages (and removed the resolv_conf usage as this is probably not the best place for it right now)

@MarkusOstermayer
Copy link

MarkusOstermayer commented Nov 10, 2024

Thanks for updating it over time 👍

Changing line 25 from

https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

to

https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable"

allows you to use this cloud-init on debian aswell.

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