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:
Step 2: Install Docker Dependencies
Next, install the necessary dependencies for Docker:
Step 3: Add Docker GPG Key
Add the official Docker GPG key to your system:
Step 4: Set up the Docker Stable Repository
Set up the Docker stable repository on your system:
Step 5: Install Docker Engine
Now, install Docker Engine, CLI, and containerd package:
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 start docker
Step 7: Verify Docker Installation
Run a simple test to ensure Docker is installed and functioning correctly:
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:
Apply executable permissions to the Docker Compose binary:
Create a symbolic link to ensure that docker-compose command can be run from any location:
Step 9: Verify Docker Compose Installation
Finally, verify that Docker Compose is installed correctly by checking its 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!