-
Update Software Repositories
sudo apt update
-
Install dependencies required to set up Docker's repository:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
-
Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
-
Set up the Docker stable repository:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
-
Update the repositories again:
sudo apt update
-
Install Docker:
sudo apt install docker-ce
-
Start Docker and enable it to start at boot:
sudo systemctl start docker sudo systemctl enable docker
-
To check the Docker version:
docker --version
-
Download Docker Compose from the official GitHub repository:
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
Note: The version
1.29.2
is mentioned here, but you might want to check the latest version on the Docker Compose release page and replace it in the URL accordingly. -
Apply executable permissions to the Docker Compose binary:
sudo chmod +x /usr/local/bin/docker-compose
-
To verify the installation:
docker-compose --version
To run Docker commands without sudo
, add the current user to the docker
group. Follow these steps to do so:
-
Add your user to the
docker
group:sudo usermod -aG docker $USER
-
Activate the changes: You need to log out and log back in to make these group membership changes effective. Alternatively, you can also use the following command to activate the membership without logging out:
newgrp docker
-
Verify that you can run Docker without
sudo
:docker run hello-world
This command should download and run the
hello-world
Docker container without needingsudo
.
For docker-compose
, once you can run Docker without sudo
, you can also run docker-compose
without sudo
since it utilizes Docker in the background.