How to check if a container runtime is installed in Linux

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, we will learn how to check if common container runtimes like Docker and Podman are installed on a Linux system. We will utilize the --version flag for each command to verify their presence and display their installed versions.

Additionally, we will explore how to inspect the /usr/bin directory to look for the binaries of these container runtimes, providing an alternative method to confirm their installation. This hands-on exercise will equip you with fundamental skills for identifying installed software on a Linux environment.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("Linux")) -.-> linux/PackagesandSoftwaresGroup(["Packages and Softwares"]) linux(("Linux")) -.-> linux/BasicSystemCommandsGroup(["Basic System Commands"]) linux(("Linux")) -.-> linux/BasicFileOperationsGroup(["Basic File Operations"]) linux(("Linux")) -.-> linux/UserandGroupManagementGroup(["User and Group Management"]) linux/BasicSystemCommandsGroup -.-> linux/echo("Text Display") linux/BasicFileOperationsGroup -.-> linux/ls("Content Listing") linux/UserandGroupManagementGroup -.-> linux/whoami("User Identifying") linux/PackagesandSoftwaresGroup -.-> linux/software("Linux Software") subgraph Lab Skills linux/echo -.-> lab-558703{{"How to check if a container runtime is installed in Linux"}} linux/ls -.-> lab-558703{{"How to check if a container runtime is installed in Linux"}} linux/whoami -.-> lab-558703{{"How to check if a container runtime is installed in Linux"}} linux/software -.-> lab-558703{{"How to check if a container runtime is installed in Linux"}} end

Check for docker with docker --version

In this step, we will check if Docker is installed on the system and find out its version. Docker is a popular platform for developing, shipping, and running applications in containers. While we won't be using Docker extensively in this introductory lab, it's a good practice to know how to check for installed software.

We can use the --version flag with most command-line tools to display their version information.

Open your terminal if it's not already open. Remember, you can find the Xfce Terminal icon on the left side of your desktop.

Type the following command and press Enter:

docker --version

If Docker is installed, you will see output similar to this:

Docker version 24.0.5, build ced0996

The exact version number might be different, but the output should start with "Docker version".

If Docker is not installed, you might see an error message like "command not found". Don't worry if you see this; it just means Docker isn't present in this specific environment. The goal of this step is simply to practice checking for software versions.

Understanding how to check software versions is important for troubleshooting and ensuring you have the correct tools for a task.

Click Continue to proceed to the next step.

Verify podman with podman --version

In this step, we will check for another containerization tool called Podman. Podman is an alternative to Docker and is often used in environments where daemonless containers are preferred. Similar to the previous step, we will use the --version flag to check if it's installed and see its version.

Open your terminal if it's not already open.

Type the following command and press Enter:

podman --version

If Podman is installed, you will see output similar to this:

podman version 4.3.1

Again, the exact version number might differ. If Podman is not installed, you will likely see a "command not found" error.

Checking for the presence and version of different tools is a fundamental skill in Linux. It helps you understand the environment you are working in and ensures compatibility when running applications or scripts.

Continue to the next step by clicking Continue.

Inspect binaries in /usr/bin

In this step, we will explore a very important directory in the Linux file system: /usr/bin. This directory contains many of the executable programs (binaries) that you use regularly from the command line.

Think of /usr/bin as a central location for user-level commands. When you type a command like ls, cd, or echo, the system looks for the corresponding executable file in directories listed in your system's PATH environment variable, and /usr/bin is typically included in that path.

We will use the ls command to list the contents of the /usr/bin directory. The ls command is used to list files and directories.

Open your terminal if it's not already open.

Type the following command and press Enter:

ls /usr/bin

You will see a long list of file names. These are the executable programs located in /usr/bin.

[... many file names ...]
zsh
zsh-beta
zsh-common
zsh-dbg
zsh-static
zsh5
zsh5.8
[... many more file names ...]

This list shows you just how many commands are available on your system! You might recognize some names from previous steps, like echo, whoami, and id.

To see a more detailed list, including file permissions, ownership, and size, you can use the -l flag with ls:

ls -l /usr/bin

This output will be much more detailed:

total 251128
-rwxr-xr-x 1 root root     35840 Mar 15  2022 [
-rwxr-xr-x 1 root root     27520 Mar 15  2022 [[
-rwxr-xr-x 1 root root     27520 Mar 15  2022 test
-rwxr-xr-x 1 root root     11000 Mar 15  2022 aarch64-linux-gnu-addr2line
-rwxr-xr-x 1 root root     11000 Mar 15  2022 aarch64-linux-gnu-ar
[... many more lines ...]

Don't worry about understanding all the details in the -l output right now. The main goal is to see the sheer number of commands available in /usr/bin and understand that this is where many common Linux commands reside.

You can also try listing the contents of other directories, like /bin, which also contains essential system binaries.

Click Continue to finish this lab.

Summary

In this lab, we learned how to check if common container runtimes like Docker and Podman are installed on a Linux system. We practiced using the --version flag with the docker and podman commands in the terminal to display their installed versions. This skill is fundamental for verifying the presence of necessary software and understanding the environment setup.

We also explored the importance of checking software versions for troubleshooting and ensuring compatibility. By executing simple commands, we can quickly determine if a container runtime is available and its specific version, which is a crucial first step before attempting to use containerization tools.