Docker CLI App Testing

Shomarri Romell Diaz
DevOps Dudes
Published in
3 min readMar 3, 2023

A guide on how to get inside containers and use the Docker CLI

Scenario:

You are a support engineer for a server farm that runs Ubuntu and CentOS. A ticket comes in that asks you to check on different curl versions for both distributions.

Objectives:

. Run an Ubuntu and a CentOS docker container

. Use both different Linux distributions to check curl CLI tool version

. Use a seperate terminal window to start bash in both CentOS:7 and Ubuntu using -it

Create docker containers for CentOS

Run the following command to create a docker container running CentOS 7 that opens a bash terminal:

docker container run --rm -it --name <container_name> centos:7 bash

We are adding the “--rm” because if you use -d with — rm , the container is removed when it exits or when the daemon exits, whichever happens first.

The “-it” command is how you start a container interactively to get inside the container and access the docker CLI. “-t” gives you a pseudo terminal, the “-i” keeps the session open to receive terminal input (interactive).

As you can see I am now in the root directory inside the CentOS container CLI.

Run the following command to update the curl version:

yum update curl

Open up a new terminal window and run the following command to verify you can see your CentOS container:

docker container ls -a

Create docker containers for Ubuntu

Now run the following command to run an Ubuntu docker container that opens a bash terminal:

docker container run --rm -it --name <container_name> ubuntu bash

Run the following command to update the curl version:

apt-get update && apt-get install -y curl

Determine curl versions

In each terminal run the following commands to determine the curl versions:

curl --version

Clean up

Run the “exit” command in both terminals.

Finally let’s determine that the containers have been removed. Because we ran our containers initially with the “— rm” command means that the container should automatically remove upon exiting.

Run the command:

docker container ls -a

As you can see from the above screenshot, there are no containers to be shown.

THE END!

If you enjoy cloud engineering content like this and would like to see more, follow me on LinkedIn.

--

--

Shomarri Romell Diaz
DevOps Dudes

DevOps ♾ | Cloud Engineer ☁️ | Linux 🐧 | AWS 🖥️ | Docker 🐳 | Find me at👇 https://www.linkedin.com/in/shomarridiaz/