How to install and configure docker In OpenSUSE Leap 15

Docker is 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.

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. 

In this guide we are going to explore various options to install docker in OpenSUSE Leap15.

Also check

# Prerequisites

To install Docker Engine, you need to have the following

  • Updated OpenSUSE Leap 15 based server
  • Internet connection
  • Basic knowledge of linux terminal

# Table of Content

  • Update system packages
  • Uninstall old versions
  • Installing docker
  • Starting and enabling Docker
  • Uninstalling Docker

# Updating system packages

Before proceeding let’s ensure that our system is up to date. Use this command to update the system and all the packages

sudo zypper refresh
sudo zypper update -y

# Installing docker

The docker package is available in the default OpenSUSE Leap packages as docker. To install the latest version of Docker Engine and containerd:

sudo zypper install docker

To confirm the installed version, use this command:

~> rpm -qi docker
Name        : docker
Version     : 20.10.12_ce
Release     : 159.1
Architecture: x86_64
Install Date: Tue Mar  8 02:58:14 2022
Group       : System/Management
Size        : 140322135
License     : Apache-2.0
Signature   : RSA/SHA256, Fri Jan 21 11:36:18 2022, Key ID 70af9e8139db7c82
Source RPM  : docker-20.10.12_ce-159.1.src.rpm
Build Date  : Fri Jan 21 11:32:05 2022
Build Host  : sheep66
Relocations : (not relocatable)
Packager    : https://www.suse.com/
Vendor      : SUSE LLC <https://www.suse.com/>
URL         : http://www.docker.io
Summary     : The Moby-project Linux container runtime
Description :
Docker complements LXC with a high-level API which operates at the process
level. It runs unix processes with strong guarantees of isolation and
repeatability across servers.

Docker is a great building block for automating distributed systems: large-scale
web deployments, database clusters, continuous deployment systems, private PaaS,
service-oriented architectures, etc.
Distribution: SUSE Linux Enterprise 15

# Starting and enabling docker

On RPM based distributions, such as OpenSUSE Leap, you need to start docker manually using the appropriate systemctl or service command. Non-root users cannot run Docker commands by default.

Use this command to start docker

sudo systemctl start docker

Confirm that docker is running by issuing the status command

~> sudo systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
     Active: active (running) since Tue 2022-03-08 02:58:24 UTC; 44min ago
       Docs: http://docs.docker.com
   Main PID: 21830 (dockerd)
      Tasks: 17
     CGroup: /system.slice/docker.service
             ├─21830 /usr/bin/dockerd --add-runtime oci=/usr/sbin/docker-runc
             └─21851 containerd --config /var/run/docker/containerd/containerd.toml --log-level warn

Mar 08 02:58:23 opensusesrv systemd[1]: Starting Docker Application Container Engine...
Mar 08 02:58:23 opensusesrv dockerd[21830]: time="2022-03-08T02:58:23Z" level=info msg="SUSE:secrets :: enabled"
Mar 08 02:58:24 opensusesrv systemd[1]: Started Docker Application Container Engine.

To enable docker on boot, use this command:

sudo systemctl enable docker

Docker will not work for no-root users or without sudo, you will get the error below if you attempt.

$ docker ps
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json": dial unix /var/run/docker.sock: connect: permission denied

To use docker without Sudo, add the current user to the docker group then re-login.

Add the user to the docker group:

$ sudo usermod -aG docker ${USER}

Then relogin as the user

$ sudo su - ${USER}

Then check that you are now part of docker

~> id
uid=1000(ec2-user) gid=100(users) groups=100(users),475(docker)

Now we can confirm that everything is working by issuing the docker run command for the hello-world image:

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:37a0b92b08d4919615c3ee023f7ddb068d12b8387475d64c622ac30f45c29c51
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

# Uninstalling Docker

If you no longer need docker in the system, use these commands to uninstall it

sudo zypper remove docker
  1. Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd

You must delete any edited configuration files manually.

# Conclusion

We have managed to install docker on an OpenSUSE Leap system. You can now download container images and run them in your system.

Last updated on Mar 20, 2024 17:19 +0300
comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy