Last active
January 5, 2024 17:42
-
-
Save vtrifonov-esfiddle/068dd818b5f929709b688c805c507e65 to your computer and use it in GitHub Desktop.
cloud-init config for ubuntu host with docker & docker-compose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 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
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
I just stumbled on this but is it really necessary to reboot after installing docker / docker-compose?