Install docker on Ubuntu/Debian
Docker is a software platform that enables you to create, deploy, and manage applications in containers. Containers are lightweight, portable, and self-contained environments that package applications with their dependencies, making them easier to move between different environments and ensuring consistency across different platforms.
Using Docker, you can package your application code, runtime, system tools, libraries, and settings into a single container image. This allows you to run your application on any Docker-enabled infrastructure, including your laptop, a local server, or a cloud platform like AWS, Azure, or Google Cloud.
Docker simplifies the process of building, shipping, and running applications, making it easier to develop, test, and deploy software in a fast and efficient way. It enables you to break down complex applications into smaller, reusable components, which can be developed and tested independently and then integrated into the larger application.
Docker offers several benefits, such as improved efficiency, scalability, and portability of applications. It also provides a consistent environment for running applications, which reduces the risk of compatibility issues and makes it easier to troubleshoot problems.
Docker is widely used by developers, IT professionals, and organizations of all sizes to improve the speed and efficiency of their application development and deployment processes. Whether you are developing a new application or migrating an existing one, Docker can help you streamline your workflow and simplify your infrastructure.
Update Your System
Before installing any new software, it is always recommended to update your system. so…
sudo apt-get update && sudo apt-get upgrade
This will update your system’s package list and help you install any available updates.
Remove old distro docker
We don’t want any old versions of docker from the distro since they can be behind the latest version and we want nothing but the coolest newest binaries!
sudo apt-get remove docker docker-engine docker.io containerd runc
Its most likely you don’t have any of these installed.
Install Docker Dependencies
Docker has some dependencies that need to be installed first. Run the following command to install the dependencies:
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release
Add Docker’s GPG Key
Docker packages are signed with a GPG key to ensure their authenticity. Run the following command to add Docker’s GPG key to your system
sudo mkdir -m 0755 -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg
sudo mkdir -m 0755 -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg
the old method of adding keys is listed below but you should use the above command.
# for ubuntu curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - # or for debian curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
Add Docker’s Repository
Next, you need to add Docker’s repository to your system’s package sources. Run the following command to add the repository.
echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Finally, you can install Docker.
sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Verify the Install
To verify that Docker is installed and working correctly, run a test container. this command will run a sample docker container called hello-world and will remove it on exit. exit it via ctrl + c
docker run --rm hello-world
If everything is working correctly, you should see the message “Hello from Docker!” in your terminal.