Skip to content

Instantly share code, notes, and snippets.

@sw360cab
Last active August 2, 2024 14:06
Show Gist options
  • Save sw360cab/ce9069daa1b087e630737d15f20b7a05 to your computer and use it in GitHub Desktop.
Save sw360cab/ce9069daa1b087e630737d15f20b7a05 to your computer and use it in GitHub Desktop.
Docker CE installation
#!/bin/sh
# installing Docker CE on Ubuntu
# Run remotely with -> curl -sfL <http://_remote-address-of-this-script_> | sh -
## Compose not installed by default
set -e
# Run as su
if [ `id -u` -ne 0 ]
then
echo "You need to be root to run this script"
exit 1
fi
apt-get update && apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release
# add GPG Key
sudo mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# add stable repository
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# install docker CE
apt-get update && apt-get -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin
LOCAL_USR=${1:-ubuntu}
usermod -aG docker $LOCAL_USR
unset DOCKER_HOST
service docker restart > /dev/null 2>&1 || true
## add alias to `docker-compose` for retro-compatibility
printf '\nalias docker-compose="docker compose"\n' >> /home/$LOCAL_USR/.bashrc
echo "Logout/Login from session may be required"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment