Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels.
It is s an open source containerization platform. It enables developers to package applications into containers - standardized executable components combining application source code with the operating system (OS) libraries and dependencies required to run that code in any environment.
In this guide we are going to explore various options to install docker in OpenSUSE Leap15.
Also check
- How to Install and Use Docker in Ubuntu 20.04
- How to install and configure docker In Fedora 34/35
- Using Ansible to install and configure docker In Rocky Linux 8/Alma Linux 8
- How to install and configure docker on Debian 11
- Getting Started With Docker Compose With Examples
- Docker as a build agent – Run Jenkins builds on Docker
Ensure your system packages are up to date
Before proceeding, let us ensure your packages are updated. Use these commands top achieve this:
|
|
Uninstall previous versions if any
Packages providing older versions of Docker are docker
, docker.io
, or docker-engine
.
Let us use this command to ensure that these packages do not exist in our system:
|
|
It’s OK if apt-get reports that none of these packages are installed.
Installing docker
You can install Docker Engine in different ways, depending on your needs:
- You can set up docker repositories and install docker using apt
- You can download the DEB packages and install manually
- You can choose to use automated convenience scripts to install Docker
Install docker engine using the repository
On a new host, the docker repositories do not exist. For the first time on a new host machine, you need to set up the Docker repository. Afterwards, you can install and update Docker from the repository.
Let us install the following packages to allow apt to use a repository over HTTPS:
|
|
Add Docker’s official GPG key:
|
|
Use the following command to set up the stable repository.
|
|
Install Docker Engine
Update the apt package index since we added a new repository:
|
|
Now let’s install the latest version of Docker Engine and containerd usi
|
|
Optional: Installing a specific version
If you have requirements that nececitate a specific version, you can do so.
To install a specific version: List the versions available in your repo:
|
|
Now you can Install a specific version using the version string from the second column, for example, 5:20.10.17~3-0~ubuntu-jammy
.
|
|
Example:
|
|
Install docker engine from a package
If you cannot use Docker’s repository to install Docker Engine, you can download the .deb file for your release and install it manually. You need to download a new file each time you want to upgrade Docker.
Go to https://download.docker.com/linux/ubuntu/dists/, choose your Ubuntu version, then browse to pool/stable/
, choose amd64
, armhf
, or arm64
, and download the .deb file for the Docker Engine version you want to install.
Install Docker Engine, changing the path below to the path where you downloaded the Docker package.
|
|
The Docker daemon starts automatically.
Verify that Docker Engine is installed correctly by running the hello-world image.
|
|
This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.
Install using the convenience script
Docker provides a convenience script at get.docker.com to install Docker into development environments quickly and non-interactively.
This example downloads the script from get.docker.com and runs it to install the latest stable release of Docker on Linux:
|
|
Verify installation
Upon installation, docker will run as a daemon. To check that docker is running, we use the systemctl status docker
command:
|
|
The Active: active (running)
shows that docker was started successfully.
We can run a hello-world
image to test that docker works as expected:
|
|
This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.
I got this output, showing that it works fine:
|
|
Executing the Docker Command Without Sudo
By default, the docker command can only be run the root user or by a user in the docker group, which is automatically created during Docker’s installation process. If you attempt to run the docker command without prefixing it with sudo or without being in the docker group, you’ll get an output like this:
|
|
If you want to avoid typing sudo whenever you run the docker command, add your username to the docker group:
|
|
To apply the new group membership, log out of the server and back in, or type the following:
|
|
You will be prompted to enter your user’s password to continue.
Confirm that your user is now added to the docker group by typing:
|
|
I see this, confirming that i now belong to the docker group
|
|
Now I can do docker: I can run alpine image
|
|
We have successfully installed docker in our system!
Uninstalling docker when it’s longer needed
To complately erase docker engine from the system, we need to uninstall the Docker Engine, CLI, and Containerd packages:
|
|
Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:
|
|
You must delete any edited configuration files manually.
Conclusion
In this guide we managed to install docker on out Ubuntu 22.04 system.