Docker in Software Development

Figo Muhammad
Siprak Team
Published in
4 min readDec 22, 2020

--

Photo by michael schaffler on Unsplash

Developing software nowadays is not an easy task. Not only the developers have to deal with the coding, but they also have to deal with other stuff such as the frameworks and architectures that are interdependent on each other. These many tools make an inflexible complex system that is too difficult to be changed or distributed. This is where the Docker comes in.

What is Docker?

Docker is an open-source platform that enables developers and system administrators to easily create, test, and deploy applications.

In standard modular units called containers, Docker bundles an application with all the packages and dependencies, such as libraries, machine resources, code, and runtime that are required in order for the application to run into a Docker image. Then, this Docker image becomes a container at runtime. This container isolates the application from other applications and ensures that it performs uniformly despite discrepancies between stages, environments, or systems.

Docker Container Characteristics

  • Standard: Docker containers nowadays become an industry standard for software development so that they can be run in many places.
  • Lightweight: Unlike virtual machines, containers share the machine’s OS system kernel and therefore do not require an OS per application. This leads to higher server efficiencies and hence reducing server renting costs.
  • Secure: Isolation between applications makes the applications safer.
Differences between virtual machines and containers — Images taken from Docker.com

How to use it?

Install the Docker Engine

The method of installing the Docker Engine is different in every operating system. I recommend you to follow the guide made by Docker. I am going to Ubuntu 18.04.5 for this article. Keep in mind that some commands may differ if you are using other than Ubuntu 18.04.5.

As you can see, I have installed the Docker Engine on my PC. I ran sudo docker run hello-world and the message is shown. This means that the installation is succeeded.

Make a Dockerfile file inside your repository

To build the Docker image, you have to make a file name Dockerfile as the place to define the steps in building the image.

These are the content of my Dockerfile as I am currently developing a ReactJS application. The content of the Dockerfile should be adjusted to your own application.

These are several explanations of the commands above:

  • FROM: This command specifies the parent image as the base of your Docker image.
  • RUN: This command executes a command inside the parent image.
  • WORKDIR: This command sets the working directory for any RUN, CMD, ENTRYPOINT, COPY, and ADD commands that follow this command in the Dockerfile.
  • COPY: This command copies new files or directories from <src> and adds them to the filesystem of the container at the path <dest>.
  • CMD: This command executes the given command whenever you run the image. So, the RUN command is executed in the building process and CMD is executed whenever you run sudo docker run command.

There are other commands such as ENTRYPOINT, EXPOSE, etc. You can learn more about them on the internet.

Build the Docker image

We can build the Docker image using sudo docker build -t <image-name> command. -targument is used to enable us to fill in the image name. My image name is praktikum-frontend. The building process consists of the steps that we have defined in Dockerfile.

Next, we can check whether the image has been built using sudo docker images command.

As you can see, our new image has been created.

Test the image

After building the image, we can run the image using sudo docker run <image-name>

Summary

Docker is a tool that is very beneficial for software developers and system administrators. Docker makes the deployment and scaling process much faster. I recommend you to learn more about Docker and use it for your next project.

Thank you!

References

--

--