Skip to content

Instantly share code, notes, and snippets.

@arahayrabedian
Last active July 16, 2023 08:18
Show Gist options
  • Save arahayrabedian/5fe6d7f6331e10aa267475e8aabbc2df to your computer and use it in GitHub Desktop.
Save arahayrabedian/5fe6d7f6331e10aa267475e8aabbc2df to your computer and use it in GitHub Desktop.
Get docker-compose (plus docker) set up and ready to go on a fresh ubuntu machine. I've done this far too often manually to test simple things on a fresh machine, so yeah. scriptify!
#!/bin/sh
# follows my interpretation of the set up guide available at
# https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#install-using-the-repository
# assumes ubuntu 16-ish and above.
set -e
# update
sudo apt-get update -y
# install pre-reqs, in case missing
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# this will just fly by, but so you can potentially see if anything
# went wrong. super unlikely, but some people are paranoid.
sudo apt-key fingerprint 0EBFCD88
# add in the repo
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
# update again because new repo
sudo apt-get -y update
# the meat of it all, install docker and pip
sudo apt-get -y install docker-ce python3-pip
# install docker-compose
sudo pip install --upgrade pip
sudo pip install docker-compose
# prep our user to not require sudo to talk to docker
sudo gpasswd -a $USER docker
newgrp docker
echo "Congrats, you should be able to docker now."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment