If you are new to the Docker environment, you don’t know what the Docker is. The short answer is that Docker is an open-source platform that provides the management interface to manage containers. Using Dockers, you can do a lot of administrative tasks on containers, like create, delete, run, stop, and configure containers. If you want to have a complete idea about Docker and containers, we have published several posts on the Dockers, Containers, architecture of Docker, and different versions of Docker Engine in this blog thesecmaster.com. Please don’t forget to read those blog posts. If you are done with reading those posts and want to start playing with Docker on the live machine, it’s the first step to start with the installation of Docker Engine. We will cover a detailed step-by-step procedure to install Docker on Ubuntu in this post. If you want to know how to install Docker on Windows or Mac, we will have dedicated ‘How To’ guides for our Windows and Mac users.
Installing Docker on Ubuntu is a great way to get started with using containers for your development or production environment. It’s simple and straightforward and makes it easy to get up and running quickly. In this article, we’ll walk you through the step-by-step procedure to install Docker on Ubuntu. We’ll cover the prerequisites, downloading and installing Docker, using the Docker command line, running a Docker container, and some troubleshooting tips. With this guide, you’ll be able to get started with Docker on Ubuntu in no time.
It literately doesn’t require anything more other than a running 64-bit version of Ubuntu machine with a good internet connection. Before starting the installation process, make sure that your system meets the following prerequisites:
You are using the 64-bit version of one of these Ubuntu versions (16.04 or higher): Ubuntu Lunar 23.04, Ubuntu Kinetic 22.10, Ubuntu Jammy 22.04 (LTS), Ubuntu Focal 20.04 (LTS), or Ubuntu Bionic 18.04 (LTS).
Your system is compatible with x86_64 (or amd64), armhf, arm64, or s390x architectures.
A user account with sudo privileges.
A good internet connection.
To check the version of your Ubuntu machine. Run any of these commands:
$ cat /etc/os-release
OR
$ hostnamectl
Once you confirm all the prerequisites are met, the next step is to start the installation of Docker on your Ubuntu. There are two approaches to installing Docker on Ubuntu.
Install Docker from the Package Manager.
Install Docker using the install Script.
We will cover both approaches here. You can follow any approach that suits your requirement. Practically, installing using the script is a more convenient way to install Docker, the traditional package manager. However, the package manager sounds more formal.
Docker Engine comes in two versions Community Edition (CE) and Enterprise Edition (EE). We will show you the installation of Community Edition in this demo tutorial. We will go over explaining the difference between the CE and EE versions here. We urge you to read this blog post Community Edition (CE) vs Enterprise Edition (EE) to know more about the differences.
If you have older versions of Docker installed on your system (known as docker
, docker.io, or docker-engine
), or any installations of containerd
or runc
, you should uninstall them before proceeding. Use the following command to uninstall:sudo apt-get remove docker docker-engine docker.io containerd runc
Before you can install Docker Engine, you need to set up the Docker repository. This can be done by following these sub-steps:
*. Update the apt package index and install packages to allow apt to use a repository over HTTPS:sudo apt update
sudo apt install ca-certificates curl gnupg
*.Add Docker’s official GPG key:sudo install -m 0755 -d /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
*.Set up the repository with the following command:echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
It’s the actual potato. Now, you can install Docker Engine by following these steps:
*. Update the apt package index:sudo apt update
*.install Docker Engine, containerd, and Docker Compose:sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
*.If you want to install a specific version, start by listing the available versions in the repository:apt-cache madison docker-ce | awk '{ print $3 }'
VERSION_STRING=5:24.0.0-1~ubuntu.22.04~jammy
sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin
Note: If you see the packages are not available or available in a different source error in the execution of the above command. Check the source of the package repository. If your system is referring to the default Ubuntu package repository, then you are not going to have the docker packages in the default Ubuntu packages. Set up the docker repository and don’t forget to update the repository upon setting up.
Use the apt-cache command to check the source of the Docker repository.sudo apt-cache policy docker-ce
After the installation, verify that Docker Engine is installed correctly by running the hello-world
image:sudo docker run hello-world
To check the Docker Engine version, run this command:sudo docker version
To Check the status of the Docker Engine service, run this command:sudo systemctl status docker
That’s it! You should now have Docker Engine installed on your Ubuntu system.
In the future, if you want to upgrade Docker Engine, follow the same installation instructions, choosing the new version you want to install during the process.
It’s no doubt that it is the fastest and easiest way to install Docker on Ubuntu. However, it has some caveats too. We recommend reading this information about the Docker Install Script.
Docker provides a streamlined script available at get.docker.com, designed to install Docker seamlessly in various development environments. The Docker installation script is not recommended for production environments due to its inherent limitations, yet its practicality for creating a provisioning script tailored to your requirements cannot be overlooked.
It is essential to consider that the Docker convenience script requires root or sudo privileges for execution. This script, known for its intelligence, attempts to detect your Linux distribution and version and then configures your package management system automatically. However, it’s important to note that it doesn’t offer much room for customization in installation parameters.
One unique feature of the Docker installation script is its ability to install dependencies and recommendations without seeking confirmation. While this may seem convenient, it may lead to the installation of a substantial number of packages, contingent on the current configuration of your host machine.
By default, the Docker convenience script installs the latest stable release of Docker, containerd, and runc. While this ensures that you’re up-to-date with the latest technology, it can lead to unexpected major version upgrades when provisioning a machine. Consequently, it is strongly advised to test upgrades in a controlled environment before deploying them to your production systems
It’s important to note that the Docker convenience script isn’t designed to upgrade an existing Docker installation. When utilizing this script to update an existing setup, dependencies may not be updated as expected, leading to potentially outdated versions.
After successfully installing Docker, you might want to perform a few post-installation steps to make sure everything is set up correctly and to optimize your Docker environment.
Most likely you will want Docker to start when the system boots. To make this happen, run the following command:
sudo systemctl enable docker
By default, Docker requires root privileges to run. However, you can configure Docker to be run by non-root users to avoid having to use sudo
it for every Docker command. If you don’t want to use sudo
it whenever you run the docker
command, create a Unix group called docker
and add users to it. When the docker
daemon starts, it makes the ownership of the Unix socket read/writable by the docker
group.
Create the docker group:
sudo groupadd docker
Add your user to the docker group:
sudo usermod -aG docker $USER
Log out and log back in so that your group membership is re-evaluated.
Verify that you can run docker commands without sudo:
docker run hello-world
If your machine uses a proxy server, Docker needs to be configured to use it. The exact steps depend on whether the proxy is HTTP or HTTPS and whether it requires authentication.
Detailed instructions can be found on the Docker proxy configuration page.
To enable memory and swap accounting on your Ubuntu system, you’ll need to set the GRUB_CMDLINE_LINUX
value in the /etc/default/grub
file. Detailed instructions can be found on the Docker runtime options page.
Please note that the exact steps might vary depending on the specific needs of your environment and the version of Ubuntu you are using.
If you wish to uninstall Docker Engine, Docker CLI, and Docker Compose, you can use these commands:
Uninstall the Docker Engine, CLI, and Containerd packages:
sudo apt purge docker-ce docker-ce-cli containerd.io
Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:
sudo rm -rf /var/lib/docker sudo rm -rf /var/lib/containerd
You must delete any edited configuration files manually.
There are several ways to install Docker on an Ubuntu system, but two methods stand out for their ease of use and widespread application: using the Ubuntu package manager and using the Docker install script. Now you know both approaches. Let’s conclude our discussion by comparing these two methods, helping you make an informed decision on which installation process suits your needs best.
Ubuntu’s package manager, apt, is a powerful tool that handles the installation, upgrade, and removal of software on your system. To install Docker using the package manager, you’d typically update your package database, ensure that dependencies are met, and then install Docker. This process grants a high level of control over the installation and allows for seamless integration with Ubuntu’s system updates.
Pros:
Control: Using the package manager gives you control over what version of Docker you’re installing.
Integration: Docker installed via the package manager will be updated along with other system updates.
Stability: The Docker version in Ubuntu’s repositories is typically a well-tested and stable version.
Cons:
Outdated Version: The Docker version in Ubuntu’s repositories might not be the latest.
Complexity: The installation process may seem complex to beginners.
The Docker install script is a convenient method provided by Docker to automate the installation process. This script detects your Linux distribution and version, configures your package management system, and installs Docker along with its dependencies. While this method is quick and easy, it lacks the control offered by a manual installation using the package manager.
Pros:
Simplicity: The install script makes the installation process quick and easy.
Latest Version: The script installs the latest stable version of Docker, ensuring you’re up-to-date.
Cons:
Less Control: The script doesn’t allow for much customization in the installation process.
Potential Risks: Automatically installing scripts from the internet may pose a security risk.
The choice between using the Ubuntu package manager and the Docker install script depends largely on your specific needs and expertise. If you prefer control over the installation process and want Docker to be integrated with your system updates, the package manager method might be for you. On the other hand, if you prefer simplicity and want the latest stable version of Docker, the Docker install script would be the way to go.
In both cases, it’s essential to understand that Docker’s power comes with complexity. No matter the installation method, it’s crucial to familiarize yourself with Docker’s capabilities and potential pitfalls to make the most out of this powerful tool. Docker’s installation process on Ubuntu, whether through the package manager or the install script, is just the first step in leveraging the power of containerization. The journey ahead is filled with opportunities to learn, experiment, and innovate. With Docker, you’re well-equipped to face the challenges of modern application development and deployment.
We hope this post helps you Understand discovering the easiest way to install Docker on Ubuntu with this step-by-step guide. We are going to end this post for now. We will cover more information about the Docker in the upcoming articles. Please keep visiting thesecmaster.com for more such technical information. Visit our social media page on Facebook, Instagram, LinkedIn, Twitter, Telegram, Tumblr, & Medium and subscribe to receive information like this.
You may also like these articles:
Arun KL is a cybersecurity professional with 15+ years of experience in IT infrastructure, cloud security, vulnerability management, Penetration Testing, security operations, and incident response. He is adept at designing and implementing robust security solutions to safeguard systems and data. Arun holds multiple industry certifications including CCNA, CCNA Security, RHCE, CEH, and AWS Security.
“Knowledge Arsenal: Empowering Your Security Journey through Continuous Learning”
"Cybersecurity All-in-One For Dummies" offers a comprehensive guide to securing personal and business digital assets from cyber threats, with actionable insights from industry experts.
BurpGPT is a cutting-edge Burp Suite extension that harnesses the power of OpenAI's language models to revolutionize web application security testing. With customizable prompts and advanced AI capabilities, BurpGPT enables security professionals to uncover bespoke vulnerabilities, streamline assessments, and stay ahead of evolving threats.
PentestGPT, developed by Gelei Deng and team, revolutionizes penetration testing by harnessing AI power. Leveraging OpenAI's GPT-4, it automates and streamlines the process, making it efficient and accessible. With advanced features and interactive guidance, PentestGPT empowers testers to identify vulnerabilities effectively, representing a significant leap in cybersecurity.
Tenable BurpGPT is a powerful Burp Suite extension that leverages OpenAI's advanced language models to analyze HTTP traffic and identify potential security risks. By automating vulnerability detection and providing AI-generated insights, BurpGPT dramatically reduces manual testing efforts for security researchers, developers, and pentesters.
Microsoft Security Copilot is a revolutionary AI-powered security solution that empowers cybersecurity professionals to identify and address potential breaches effectively. By harnessing advanced technologies like OpenAI's GPT-4 and Microsoft's extensive threat intelligence, Security Copilot streamlines threat detection and response, enabling defenders to operate at machine speed and scale.