Step-by-Step Guide
- Update the Package Index
Open a terminal and update the package index to ensure you have the latest information about available packages:
sudo apt update
- Install Necessary Packages
Install the necessary packages for Docker:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
- Add Docker’s Official GPG Key
Add Docker’s official GPG key to your system:
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- Set Up the Docker Repository
Add the Docker APT repository to your system:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- Update the Package Index Again
Update the package index again to include the Docker repository:
sudo apt update
- Install Docker
Install Docker using theapt
package manager:
sudo apt install docker-ce docker-ce-cli containerd.io
- Verify Docker Installation
Check the Docker version to ensure it is installed correctly:
docker --version
You should see the Docker version information displayed.
- Start and Enable Docker
Ensure Docker starts on boot:
sudo systemctl start docker
sudo systemctl enable docker
- Add Your User to the Docker Group (Optional)
To run Docker commands withoutsudo
, add your user to the Docker group:
sudo usermod -aG docker $USER
Log out and log back in for the changes to take effect, or use the following command to apply the changes immediately:
newgrp docker
- Test Docker Installation
To test Docker, run thehello-world
container:docker run hello-world
If Docker is installed correctly, you should see a message saying “Hello from Docker!” - Install Docker Compose (Optional)
Docker Compose is a tool for defining and running multi-container Docker applications. To install Docker Compose, download the binary:bash 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
Apply executable permissions to the binary:bash sudo chmod +x /usr/local/bin/docker-compose
Verify the installation:bash docker-compose --version