In this tutorial, we are going to explain how to install Docker CE on Ubuntu 22.04 OS.
Docker CE or Docker Community Edition is an open-source application that provides encapsulated environments (containers) that allow applications to run separately from each other on the server.
The containers are isolated from the structure of the OS, and they can not interfere with the work of the main services on the server. Many developers and administrators use Docker on a daily basis. Besides the installation, we will list some of the most used docker commands.
Installing Docker CE on Ubuntu 22.04 is straightforward and may take up to 10 minutes. Let’s get started!
Table of Contents
Prerequisites
- A server with Ubuntu 22.04 as OS
- User privileges: root or non-root user with sudo privileges
Step 1. Update the System
Update the system packages to the latest versions available before you start any installation on a fresh OS.
sudo apt-get update -y && sudo apt-get upgrade -y
Step 2. Install Docker Dependencies
Before we install Docker, we need to install some Docker dependencies:
sudo apt-get install apt-transport-https curl gnupg-agent ca-certificates software-properties-common -y
Step 3. Add Docker Key and Repo
The docker repository, by default, is not included in the official repository of Ubuntu 22.04. First, we will add the key, then the repo.
To add the GPGK key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Once the GPGK key is added, we can proceed to add the repo:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
Step 4. Install Docker
Once the key and repo are added, we can install Docker with the following commands:
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
After successful installation, start and enable the docker service:
sudo systemctl enable docker && sudo systemctl start docker
To check the status of the service, execute the following command:
sudo systemctl status docker
You should receive the following output:
root@host:~# sudo systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2023-02-09 03:02:24 CST; 10s ago TriggeredBy: ● docker.socket Docs: https://docs.docker.com Main PID: 2361 (dockerd) Tasks: 9 Memory: 26.2M CPU: 780ms CGroup: /system.slice/docker.service └─2361 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Docker service is not running on a specific port, but if you want to check the process, you can execute the following command:
ps aux | grep docker
You will receive the following output:
root@host:~# ps aux | grep docker root 2361 0.0 1.8 1390760 72376 ? Ssl 03:02 0:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock root 2792 0.0 0.0 9076 2324 pts/0 S+ 03:42 0:00 grep docker
Step 5. Using Docker
In this paragraph, we will show you some of the docker commands that might be useful for you.
Check Docker version: docker -v
Listing the running containers: docker ps
Start Docker container: docker start “id-of-container”
Stop Docker container: docker stop “id-of-container”
Restart Docker container: docker restart “id-of-container”
Remove Docker container: docker remove “id-of-container”
Information of Docker: docker info
To read more about docker and its usage, you can always use the command docker help, and you will get a complete list of all docker commands with full explanations:
Usage: docker [OPTIONS] COMMAND A self-sufficient runtime for containers Common Commands: run Create and run a new container from an image exec Execute a command in a running container ps List containers build Build an image from a Dockerfile pull Download an image from a registry push Upload an image to a registry images List images login Log in to a registry logout Log out from a registry search Search Docker Hub for images version Show the Docker version information info Display system-wide information Management Commands: builder Manage builds buildx* Docker Buildx (Docker Inc., v0.10.2) compose* Docker Compose (Docker Inc., v2.15.1) container Manage containers context Manage contexts image Manage images manifest Manage Docker image manifests and manifest lists network Manage networks plugin Manage plugins scan* Docker Scan (Docker Inc., v0.23.0) system Manage Docker trust Manage trust on Docker images volume Manage volumes Swarm Commands: swarm Manage Swarm . . . . .
That’s it! You just learned how to install Docker Community Edition on Ubuntu 22.04. If learning Docker is difficult, you can sign up for one of our NVMe VPS hosting plans, and we will install and configure Docker CE on Ubuntu 22.04 for you. All you need to do is submit a support ticket; our admins will help you immediately. We are available 24/7.
If you liked this post about installing Docker CE on Ubuntu 22.04, please share it with your friends on social networks using the buttons on the left or leave a reply below. Thanks.
First of all, thank you for your article.
Just two suggestions:
1) Create the file /etc/apt/trusted.gpg.d/docker.gpg instead of using file /etc/apt/trusted.gpg to store the gpg key.
curl -sS https://download.docker.com/linux/ubuntu/gpg | gpg –dearmor | sudo tee /etc/apt/trusted.gpg.d/docker.gpg >/dev/null
2) Use the repository Docker for Ubuntu 22.04 jammy
sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu jammy stable”
Thanks again for your article which allowed me to install docker quickly under ubuntu 22.04!