Docker is an open source project that allows us to easily run applications in isolated containers. Those who are using Ubuntu 22.04 LTS and want to install Docker CE to run containers of various Linux applications can take this tutorial.
Another advantage of Docker containers is that they can build on and communicate with each other. Examples of these applications would be an Apache server or a MySQL database.
Compared to normal virtual machines, we don’t need every container to run a full operating system. I mean, if we want to run a web server separate from the database server, we will have to start two full virtual machines including the operating system. This is not the case with docker, in this one the underlying kernel will be the same and two independent containers can be started for the respective servers without installing the full operating system, instead a lightweight Docker image will do the job.
Additionally, Docker is a cross-platform project, so regardless of the operating system (Windows, Linux, or macOS) it will run the command which will be the same for everyone and there will be no compatibility issues between containers.
Steps to install Docker CE on Ubuntu 22.04 LTS Jammy Jellyfish
1. System update and installation of some tools
sudo apt update sudo apt install ca-certificates curl apt-transport-https
2. Add a GPG key
To download the Docker packages on Ubuntu we need to add the GPG key used to sign the Docker packages by its developer otherwise the system will throw an error and not be able to use the repository.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
3. Add a Docker repository on Ubuntu 22.04
We can install the docker using the default Ubuntu Jammy system repository, however, the version available will not be the latest. Therefore, manually add the official Docker repository using the command block below.
Copy and paste it whole command block in your terminal:
echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
4. Install Docker Engine on Ubuntu 22.04
Finally, we configured all the required things that we needed. Now just run the system update command to refresh the repository cache and update the already installed packages. After that use the APT packages to get all the Docker tools we need to start building containers.
sudo apt update sudo apt-get install docker-ce docker-ce-cli containerd.io
To verify that the Docker service is running:
systemctl status docker
In case it doesn’t work, use:
sudo systemctl start docker
5. Use docker without sudo
Once the installation is complete we need to add our current system user to the Docker group, otherwise every time we need to use ‘
sudo‘with each Docker command.
sudo usermod -aG docker $USER newgrp docker
To check the version:
6. Create a container
Now we can start creating our first container. For example, let’s say you want to create a Debian Bullseye container. For that, we are going to pull its docker image.
docker pull debian
Create a container:
docker create -it --name test debian
docker start test
Get the command line of the installed container:
docker attach test
How to install the Ubuntu 22.04 LTS container on Docker.
Download and install Ubuntu 22.04 LTS ISO on VirtualBox