A Complete Beginners Introduction To Docker

Shomarri Romell Diaz
DevOps Dudes
Published in
5 min readFeb 28, 2023

A mini walkthrough to introduce the complete beginner to containerization Docker technology

Docker Overview:

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.

There are three core components to Docker. The docker image, docker registry and the docker container, also known as build, ship and run.

  1. Docker Image

Is the universal packager which can be uses across operating systems and cross platform. We use the “docker build” command when creating the image

2. Docker Registry

Is used for app distribution. A Docker registry is a storage and distribution system for named Docker images. The “docker push” command pushes images to a container registry and the “docker pull” command pulls images from the registry.

3. Docker Container

Docker is an operating system for containers. Similar to how a virtual machine virtualizes (removes the need to directly manage) server hardware, containers virtualize the operating system of a server. Docker is installed on each server and provides simple commands you can use to build, start, or stop containers.

Getting hands on with Docker

Please click here to navigate to the “play with docker website”. Play with Docker is an online interface that you can use to quickly spin up multiple docker instances.

In order to sign in to ‘Play with docker’ you first must have a Docker account. if you don’t already have one, click here to sign up for FREE Docker account, then navigate back to the play with docker login page and sign in with your Docker credentials.

Running your first container

On the left hand of the page select “Add new instance” every instance you create on this platform will run for and timeout in approximately 4 hours.

Once you start your instance your screen should show your instance terminal.

The first command we will run will give us details about the client and the engine/server, type in the following command:

docker version

Understand that when you type commands, you are typing them on the “client” which talks to the “engine” in the background which executes the commands we type through the API.

To clear the screen type in the command:

clear

Next, let’s run a container with an Apache web page installed. Type in the following command:

docker run -d -p 8800:80 httpd

The “-d” stands for “detach” meaning to run in the background. The “-p” stands for open up a port and publish it on my host IP so that I can access it remotely.

“8800” is the port our host will listen on and “:80” is the default container running Apache.

“httpd” is the image of the Apache daemon we want to run.

What happens when we run the above command is the downloading of all the layers which make up the full image eg the networking, virtual interface, IP address, files systems etc.

To verify the machine is up and running type in the following command:

curl localhost:8800

Remember that :8800 is port that is being listened on.

Your output should look as the above image, the response is the default apache webpage.

To view the list of all the containers you currently have running type in the command:

docker ps

Of course at this moment we only have one docker instance running.

Running multiple Apache servers

It is possible to run all the commands we have learned and run multiple apache servers at once, however we must use a separate “public port”. This is the one aspect that cannot be the same! You cannot use the same port on more than one application at the same time.

Let’s run a new docker service but utilise a different port. Run the following command.

docker run -d -p 8801:80 httpd

Run the “docker ps” command again and you will now see both container instances listed.

If you would have tried to use the :8800 port again you would have gotten an error as we cannot use the same port twice.

That concludes our beginner demo. To shut down our docker containers click the “close session” button on the top left of the page to free up the used container space.

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/