How To Install and Use Docker on Ubuntu 22.04
Last Updated :
22 Aug, 2024
Docker is a platform used by developers to automate the deployment of applications within containers. The containers include all the necessary components for the application to run, ensuring consistent behavior across various environments. In this guide, we'll walk through the process of installing Docker on Ubuntu 22.04, explore key Docker concepts, and how to use Docker.
What is Docker?
Docker is a platform that supports container creation, deployment, and management. Containers are self-contained environments that package an application and all its dependencies together, making it easy to move applications between different environments without worrying about social issues.
Key Terminologies
- Image: A lightweight, self-contained, executable package that contains everything required to run a software application, including the code, runtime, libraries, environment variables, and configuration files.
- Container: A running instance of a Docker image. Containers operate in isolation from each other and the host system.
- Docker Hub: A cloud-based repository where Docker users can store, share, and access Docker images.
- Dockerfile: A script that outlines a set of instructions for building a Docker image.
Prerequisites
- A system running Ubuntu 22.04.
- A user account with 'sudo' privileges.
Step-by-Step Process to Install Docker on Ubuntu 22.04
In this section, we will discuss the step-by-step installation of docker using the 'apt' repository
Step 1: Update Your System
First, update your system's package index to ensure that it is up-to-date. Open the terminal in your Linux system and run the bash commands shown below.
sudo apt update
sudo apt upgrade
Step 2: Set up Docker's 'apt' repository
Run the bash commands shown below in your Linux terminal to set up Docker's 'apt' repository.
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Step 3: Install the Docker packages
To install the Docker packages, run the bash command shown below in the terminal:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 4: Verify Docker Installation
To verify that Docker is installed and running, run the bash command shown below in the terminal:
sudo systemctl status docker
Basic Docker Commands
1. Pull an Image from Docker Hub
- To pull an image from Docker Hub, use the 'docker pull' command:
sudo docker pull hello-world
2. Run a Container
- Once the image is pulled, you can create and run a container using:
sudo docker run hello-world
This command runs the 'hello-world' container, which prints a welcome message and exits.
3. List Running Containers
- To list running containers, use:
docker ps
Conclusion
Docker is a powerful tool for building, deploying, and managing applications in a distributed environment. After completing this tutorial, you should have Docker installed on your Ubuntu 22.04 system and be familiar with basic Docker commands. Docker's ability to package applications and their dependencies into containers makes it an essential tool for developers and administrators.
Similar Reads
How to Install NVM on Ubuntu 22.04
Whether you are developing a web application, working with a Node.js-based project, or learning Node.js in general, NVM makes it easier to work with your Node.js environments in Ubuntu. In essence, NVM (Node Version Manager) is a useful tool for working with multiple versions of Node.js on your comp
5 min read
How to Install and Configure Docker in Ubuntu?
Docker is a platform and service-based product that uses OS-level virtualization to deliver software in packages known as containers. Containers are separated from one another and bundle their software, libraries, and configuration files. Docker is written in the Go language. Docker can be installed
6 min read
How to Install Docker on Debian?
Docker Service Product is the essential tool used for the development purpose of any software where the said software needs to be passed through different development phases. The Installed Docker Service makes Operating System-Level Virtualization to create Docker Containers. Docker can easily be in
4 min read
How to Install Docker on Windows?
Before understanding the concept of Docker, let's first discuss the concept of Hypervisors. So in an IT Company, or any cooperation, there is a development team, a testing team, and an operation team for developing the application, testing it, and deploying it. Now suppose the developers are working
13 min read
How to Install and Run Jekyll on Docker?
Jekyll is an open-source software used to develop websites. Jekyll is a free application present on the internet. The word open source refers that the application being free to use. Jekyll is the application used to develop static websites. Jekyll generally takes the text in the user's favorite mark
4 min read
How To Install Docker On AWS EC2 ?
You can use the following instructions to install Docker on an AWS EC2 instance. Note that depending on the Linux distribution your EC2 instance is running, there may be differences in certain commands or processes. What is Docker?Docker is an OS-level virtualization that provides tools for building
3 min read
How to Install Docker on CentOS?
Quick Preview to Install Docker on CentOS:Installation of Docker on CentOS:Open CentOS Terminal.Execute the command yum update in the Root Menu.Run the command yum install -y yum-utils device-mapper-persistent-data lvm2.Execute the command yum-config-manager --add-repo https://download.docker.com/li
4 min read
How to Install Docker using Chocolatey on Windows?
Installing Docker in Windows with just the CLI is quite easier than you would expect. It just requires a few commands. This article assumes you have chocolatey installed on your respective windows machine. If not, you can install chocolatey from here. Chocolatey is a package manager for the Windows
4 min read
How to Install Docker on Amazon Linux
Docker is a tool which helps to automate the deployment of applications in containers to make sure that particular applications can work efficiently in different environments without any errors.It helps developers to build, ship, and run application faster and more reliable way. In this article, we
3 min read
How to Install and Configure Kubernetes on Ubuntu?
Kubernetes is open-source software that helps to solve problems related to container-based software automation. It is like a container based system, which helps to distribute out the work that needs to be executed while testing software. Kubernetes are portable in nature. That is why it is widely us
8 min read