Install docker and docker compose on ubuntu 20.04

Teeppiphat Phokaewkul
1 min readFeb 2, 2023

--

On Ubuntu 20.04, perform the following steps to install Docker and Docker Compose:

Update the package index:

sudo apt-get update

Install dependencies:

sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common

Add Docker’s GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Add the Docker repository to the apt sources list:

sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

Update the package index again:

sudo apt-get update

Install Docker:

sudo apt-get install -y docker-ce docker-ce-cli containerd.io

Verify the Docker installation:

sudo docker run hello-world

if found error like this:

docker ps

permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1
.24/containers/json": dial unix /var/run/docker.sock: connect: permission denied

try this for fix:

sudo chmod 666 /var/run/docker.sock

Install Docker Compose(version 1):

sudo curl -L "https://github.com/docker/compose/releases/download/1.28.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Apply executable permissions to the Docker Compose binary:

sudo chmod +x /usr/local/bin/docker-compose

Verify the Docker Compose installation:

docker-compose --version

--

--

Teeppiphat Phokaewkul

จดไปเรื่อย ไว้อ่านกันลืม