Docker is an open-source platform for developing, shipping, and running applications inside containers. Docker Compose simplifies the process of managing multiple Docker containers. This guide will help you install Docker and Docker Compose on an Ubuntu system step-by-step.
Table of Contents
- Update Package Repositories
- Install Docker Dependencies
- Add Docker GPG Key
- Set up the Docker Stable Repository
- Install Docker Engine
- Enable and Start Docker Service
- Verify Docker Installation
- Install Docker Compose
- Verify Docker Compose Installation
Prerequisites
- Ubuntu 18.04 or later
- A user with sudo privileges
Let's get started!
Step 1: Update Package Repositories
First, ensure your package repositories are up to date:
sudo apt update
Step 2: Install Docker Dependencies
Next, install the necessary dependencies for Docker:
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
Step 3: Add Docker GPG Key
Add the official Docker GPG key to your system:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Step 4: Set up the Docker Stable Repository
Set up the Docker stable repository on your system:
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
Step 5: Install Docker Engine
Now, install Docker Engine, CLI, and containerd package:
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io
Step 6: Enable and Start Docker Service
Enable and start the Docker service to ensure it runs on system startup:
sudo systemctl enable docker
sudo systemctl start docker
Step 7: Verify Docker Installation
Run a simple test to ensure Docker is installed and functioning correctly:
sudo docker run hello-world
If everything is set up correctly, youโll see a message indicating a successful installation.
Step 8: Install Docker Compose
Download the Docker Compose binary from the official GitHub repository:
sudo curl -L "https://github.com/docker/compose/releases/latest/download/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
Create a symbolic link to ensure that docker-compose
command can be run from any location:
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
Step 9: Verify Docker Compose Installation
Finally, verify that Docker Compose is installed correctly by checking its version:
docker-compose --version
Conclusion
Congratulations! You have successfully installed Docker and Docker Compose on your Ubuntu system. You are now ready to start using Docker to containerize your applications and Docker Compose to manage multi-container applications. Happy coding!
Top comments (0)