A install script for docker and docker-compose on fresh Ubuntu 20.04 systems to get a quick headstart
Just run the script in a terminal to install docker, docker-compose and make it executable without typing sudo for every docker command.
git clone https://github.com/Visuals3D/install-docker.git
cd ./install-docker
sudo chmod +x install-docker.sh
./install-docker.sh
If you want to you can follow this steps manually on your own to install docker, docker-compose and remove the need for sudo
Remove older Version
sudo apt-get remove docker docker-engine docker.io containerd runc
Install dependencies
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release
Add official key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Add Repo
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Finally Install Docker
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
Test Installation
sudo docker --version
Download Package
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Make it executable
sudo chmod +x /usr/local/bin/docker-compose
Create sym Link
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
Test Installation
docker-compose --version
Create a docker user group
sudo groupadd docker
Add own user to group
sudo gpasswd -a $USER docker
Refresh group to apply changes
newgrp docker
Test sudoless docker
docker ps -a