A Complete Beginner’s Guide to Docker

Related Articles

Docker is an open source platform that allows us to create, deploy and manage container applications. In this article, we will look at

What is a stab?

Docker is a container management service. The whole purpose of Docker is to make it easier for developers to create apps, send them to containers and then deploy them wherever they want. Now let’s discuss what containers are.

Containers are a solution to the challenge of moving software from one computing environment to another and running it consistently. It can be from a test laptop to a testing environment, or from a real data center computer to a virtual machine in a private or public cloud.

A container is an entire runtime environment packaged in one package: a program, along with all of its dependencies, libraries and other components, and configuration files needed to run it. Now that you have some knowledge about Docker and Containers, let’s understand why we should use Docker.

Benefits of using Docker

Before installing a docker and docerizing app, let’s first understand what are the benefits of Docker. Running applications in containers brings a number of benefits such as


Docker containers are usually faster and less resource-intensive than virtual machines because containers do not contain an operating system whereas virtual machines do.


You can quickly create new containers if the demand for your applications requires them. When using multiple containers you can take advantage of a variety of container management options.

Quick deployment

Docker manages to reduce the layout to seconds. This is because it produces a container for each process and does not boot an operating system.

CI efficiency

Docker allows you to create a container image and use it throughout the deployment process. The ability to isolate independent steps and perform them in parallel is a major advantage.

Now let’s learn the facts about Docker that you may not know 🙂

Stabbing facts

  • Docker’s adoption has risen 30% in the past year.
  • PHP, Ruby, Java and Node are the main programming frameworks / languages ​​used in containers.
  • 2/3 of the organizations that try Docker end up using it. Most of the companies that fit did so within 30 days of the first use of production, and in fact all the remaining efforts were converted within 60 days.
  • Docker offers a large library of pre-built images. At the time of writing, there are more than 400,000 public stabbing images available online.

Docker installation


If you are using a Mac with Apple Silicone, you need to install Rosetta 2, to do this just run the command down in your terminal.


Visit it Link And select your mac chip, click the blue button with your mac chip label on it. Once done, the DMG file will be downloaded, double-click it, and you should drag the docker logo into the applications folder

Once copied, you can access the docker from the applications folder.

Screenshot 2021-10-07 at 07.52.44.png


To install Docker on Linux you can simply run the command below in your terminal, it will install everything related to docer on your Linux computer.

wget -qO- | sh

Docking of the node.js application

Dockerizing is the process of packaging, deploying and running applications using Docker containers. In this article, we are going to dockerize the node.js application, but before starting it, if you are using VS code, it is best to install Stabbing ending.

Screenshot 2021-10-08 on 08.01.53.png

Docker extension makes it easy to build, manage and deploy container applications from Visual Studio Code. It also provides one-click debugging of Node.js, Python and .NET Core within a container.

Environment setting

In this article, I’m going to create a simple node.js app that sends a accept request, but if you want, you can also continue to process your current application throughout this article.

To create a node.js application from scratch, you just need to launch it

npm init

Once you complete it, a package.json A file will be created. You can now create a new file named app.js And this is going to be the file where we will connect it. To send / receive the http request we need to configure express as well, so we also need to install express.js. To do this just run

npm i express

And once that is done, you can create a simple GET request. Here is the code for it 🙂

const express = require("express");

const app = express();

app.get("", (req, res) => 
    message: "Hey, server is running :D",

const port = process.env.PORT || 3000;
app.listen(port, () => 
  console.log(`Server is running on port $port`);

You can launch this app by launching node app.js And your server will start at port 3000. You can open your browser and go to localhost: 3000 where your application is running and you will see a similar output (below image).

Screenshot 2021-10-08 at 17.51.30.png

Now that we have the basic definition of the node.js app, let’s start learning about Dockerfile.

Docker file

Dockerfile is a text file that contains all the commands that a user might use to construct an image from the command line.


Now, go ahead and create a Dockerfile within your project directory. The first thing we need to do is define from which image we want to build. Copy the code below and paste it into your docerfile. Do not worry I’m going to explain each line 🙂

FROM node:14


COPY package*.json ./

RUN npm install

COPY . .



CMD [ "node", "start" ]

In the code above

  • M Initializes a new construction phase and configures the base image for the following instructions
  • WORKDIR Used to set up the work directory for all of the following instructions
  • copy Allows you to copy files from a specific location to the Docker image
  • run Allows you to install the application and packages required for it
  • Reveal It is a way to keep track of the ports in use, but it does not map or open ports.
  • CMD Specifies the instruction to be executed when container Docker starts

We now have a full set of instructions for building a docker image, let’s build it 🙂

Stabbing a picture

To build a docker image, we need to use the Build command below

docker build [OPTIONS] PATH | URL | -

Which in our case will be

docker build -t <your username>/nodedemo .

You need to rename your Docker Hub

Once this process is complete, a docker image will be created. To see all your stabber pictures, run the following command in your terminal

docker images

Stabbing containers

Now that we have your docer images, we can use them as a base image to create other images or we can use them to launch containers.

Typically, we use this image to push it to register a container that may be a Docker Hub or any cloud provider. But in this article we are going to push our image to the docker hub. To do this just run

docker push <your username>/nodedemo

If you received a denial of access error, you must log in to your Docker Hub account to do so

docker login

And enter your email and password in your terminal. Once you upload your image to the Docker hub, you can access it on your Docker Hub profile.


This is this article. I hope you found this article useful, if you need any help please let me know in the comments section.

You can find the source code in my Github database Here .

Do you want to buy me coffee, you can do it Here.

Let’s connect Twitter and LinkedIn.

👋 Thanks for reading, see you next time



Please enter your comment!
Please enter your name here

Popular Articles