/ Tutorial //
How To Install and Use Docker on Ubuntu 22.04
By Brian Hogan and Tony Tran
Not using Ubuntu 22.04?Choose a different version or distribution.
Introduction
Docker is an application that simplifies the process of managing application processes in containers. Containers let you run your applications in resource-isolated processes. They’re similar to virtual machines, but containers are more portable, more resource-friendly, and more dependent on the host operating system.
For a detailed introduction to the different components of a Docker container, check out The Docker Ecosystem: An Introduction to Common Components.
In this tutorial, you’ll install and use Docker Community Edition (CE) on Ubuntu 22.04. You’ll install Docker itself, work with containers and images, and push an image to a Docker Repository.
Prerequisites
To follow this tutorial, you will need the following:
- One Ubuntu 22.04 server set up by following the Ubuntu 22.04 initial server setup guide, including a
sudo
non-root user and a firewall. - An account on Docker Hub if you wish to create your own images and push them to Docker Hub, as shown in Steps 7 and 8.
Step 1 — Installing Docker
The Docker installation package available in the official Ubuntu repository may not be the latest version. To ensure we get the latest version, we’ll install Docker from the official Docker repository. To do that, we’ll add a new package source, add the GPG key from Docker to ensure the downloads are valid, and then install the package.
First, update your existing list of packages:
Next, install a few prerequisite packages which let apt
use packages over HTTPS:
Then add the GPG key for the official Docker repository to your system:
Add the Docker repository to APT sources:
Update your existing list of packages again for the addition to be recognized:
Make sure you are about to install from the Docker repo instead of the default Ubuntu repo:
You’ll see output like this, although the version number for Docker may be different:
docker-ce:
Installed: (none)
Candidate: 5:20.10.14~3-0~ubuntu-jammy
Version table:
5:20.10.14~3-0~ubuntu-jammy 500
500 https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
5:20.10.13~3-0~ubuntu-jammy 500
500 https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
Notice that docker-ce
is not installed, but the candidate for installation is from the Docker repository for Ubuntu 22.04 (jammy
).
Finally, install Docker:
Docker should now be installed, the daemon started, and the process enabled to start on boot. Check that it’s running:
The output should be similar to the following, showing that the service is active and running:
Output● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-04-01 21:30:25 UTC; 22s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 7854 (dockerd)
Tasks: 7
Memory: 38.3M
CPU: 340ms
CGroup: /system.slice/docker.service
└─7854 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Installing Docker now gives you not just the Docker service (daemon) but also the docker
command line utility, or the Docker client. We’ll explore how to use the docker
command later in this tutorial.
--------------------------------------------------------------------------------------------------------------------
version of this tutorial. While the installation differs, in general the actual usage involves dropping the hyphen from docker-compose
calls to become docker compose
. For full compatibility details, check the official Docker documentation on command compatibility between the new compose
and the old docker-compose
.
Step 1 — Installing Docker Compose
To make sure you obtain the most updated stable version of Docker Compose, you’ll download this software from its official Github repository.
First, confirm the latest version available in their releases page. At the time of this writing, the most current stable version is 2.3.3
.
Use the following command to download:
Next, set the correct permissions so that the docker compose
command is executable:
To verify that the installation was successful, you can run:
You’ll see output similar to this:
OutputDocker Compose version v2.3.3
--------
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-22-04
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-22-04
No hay comentarios:
Publicar un comentario