Inspired by syntaqx/cloud-init.yaml.
This version uses the built-in apt module to configure docker repository. Also, rather than downloading the signing key using curl on init, which can be insecure, it has the GPG signing key inline explicitly. Please check the signing key yourself and update it in case docker rotated the signing key.
Tested on Ubuntu 24.04 (Noble).