Skip to content

Instantly share code, notes, and snippets.

@vtrifonov-esfiddle
Last active January 5, 2024 17:42
Show Gist options
  • Save vtrifonov-esfiddle/068dd818b5f929709b688c805c507e65 to your computer and use it in GitHub Desktop.
Save vtrifonov-esfiddle/068dd818b5f929709b688c805c507e65 to your computer and use it in GitHub Desktop.
cloud-init config for ubuntu host with docker & docker-compose
#cloud-config
groups:
- docker
users:
- default
# the docker service account
- name: docker-service
groups: docker
package_upgrade: true
packages:
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common
runcmd:
# install docker following the guide: https://docs.docker.com/install/linux/docker-ce/ubuntu/
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get -y update
- sudo apt-get -y install docker-ce docker-ce-cli containerd.io
- sudo systemctl enable docker
# install docker-compose following the guide: https://docs.docker.com/compose/install/
- sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- sudo chmod +x /usr/local/bin/docker-compose
power_state:
mode: reboot
message: Restarting after installing docker & docker-compose
@LaurentDumont
Copy link

I just stumbled on this but is it really necessary to reboot after installing docker / docker-compose?

@vtrifonov-esfiddle
Copy link
Author

@LaurentDumont this is to finish the first boot stage. It seems that for cloud-init it is necessary to differentiate it from subsequent boots: https://cloudinit.readthedocs.io/en/latest/topics/boot.html#first-boot-determination

@UromPLAt
Copy link

UromPLAt commented Jun 7, 2022

Why the need to create the docker-service user and add it to the docker group? isn't this handled by the Docker installation itself?

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