Docker and Docker compose Installation

Hasitha Upekshitha
1 min readFeb 26, 2024

--

Installing Docker:
1. Update Package Repositories:
Ensure your package repositories are up to date:
#sudo apt update

2. Install Docker Dependencies:
#sudo apt install -y apt-transport-https ca-certificates curl software-properties-common

3. Add Docker GPG Key:
#curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg — dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

4. Set up the Docker Stable Repository:
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

5. Install Docker Engine:
#sudo apt update
#sudo apt install -y docker-ce docker-ce-cli containerd.io

6. Enable and Start Docker Service:
#sudo systemctl enable docker
#sudo systemctl start docker

7. Verify Docker Installation:
Run a simple test to ensure Docker is installed and working:

#sudo docker run hello-world
If everything is set up correctly, you’ll see a message indicating a successful installation.

Installing Docker Compose:
1. Download Docker Compose Binary:

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

2. Apply Executable Permissions:
#sudo chmod +x /usr/local/bin/docker-compose

3. Create Symbolic Link:
#sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

4. Verify Docker Compose Installation:
#docker-compose — version

--

--