How to Install Docker on Rocky Linux 8 – Command line method

In this blog, we will learn how to install docker on Rocky Linux 8 but before that lets gets into understanding what is this docker all about.

Introduction

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code, you can significantly reduce the delay between writing code and running it in production.

Pre-requisite

A Rocky Linux 8 Host server with sudo privileges to the non-root user. To get with the installation you can refer our previous blog post How to Install Rocky Linux 8

Installing the docker

To get the latest docker packages installed we will configure the docker repo. Prior to that we will make sure our host system is updated

$ sudo dnf check-update

Add the Docker official repository. Please note there is no Rocky Linux specific repository from Docker, Rocky Linux is based upon CentOS and can use the same repository. 

$ sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Install the docker packages

$ sudo dnf install docker-ce docker-ce-cli containerd.io

Start the service

$ sudo systemctl start docker

Verify if the services is running

$ sudo systemctl status docker

Output :

Output

● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2023-12-18 06:53:52 CDT; 1 weeks 3 days ago
Docs: https://docs.docker.com
Main PID: 552 (docker)

Make the service persistent across the reboot

$ sudo systemctl enable docker

Configuring Non-root user for docker

Running the docker command requires root privileges — you will always have to prefix the command with sudo. But it is also possible to run as a normal non-root user if added to the docker group, which is automatically created during the installation of Docker. Let try to add the user to the required group

$ sudo usermod -aG docker $(whoami)

Usage of the docker commands

Now that the docker has been installed and configured let us get familiar with the docker commands. Using the docker commands follow the below syntax

$ docker [option] [command] [arguments]

To view all available subcommands, type:

$ docker

Output :

Output


attach Attach to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on a container or image
kill Kill a running container
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
network Manage Docker networks
pause Pause all processes within a container
port List port mappings or a specific mapping for the CONTAINER
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart a container
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop a running container
tag Tag an image into a repository
top Display the running processes of a container
unpause Unpause all processes within a container
update Update configuration of one or more containers
version Show the Docker version information
volume Manage Docker volumes
wait Block until a container stops, then print its exit code

If you want to view the switches available to any specific command run :

$ docker docker-subcommand --help

For viewing system-wide information, run:

$ docker info

For more information on docker installation & configuration you can always refer to their official website Get Docker

Leave a comment