Skip to content

Instantly share code, notes, and snippets.

@syntaqx
Last active June 12, 2024 12:59
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 Jul 26, 2022

Appreciate the comment! This is a pretty old cloud-init file, so the one I use these days has changed quite a bit, but the reason the user was explicit was to ensure that the user was added to the right group, which I believe the default user did not have.

@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)

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