Docker — the story of a ship

Inez Nabila
Pilar 2020
Published in
4 min readDec 22, 2020

Have you ever tried running another person’s code from your device? Does it contain a lot of error? Dependencies error? Yeah, that! Most of the time, a new application that we just pulled or cloned from GitLab will not work right away. This is because there are a lot of dependencies that we had to install in order for the code-or app-to work. Plus, we have to do this all over again when we are using a different device. Isn’t this tiring and adding more workload that we need to do?

Photo by Shahadat Rahman on Unsplash

Do not fret! Docker is here!

Docker is a software development platform which makes it easy for developers to develop and deploys application(s) inside of neatly packaged inside a virtual containerized environments. Simply put, it will work the same way, wherever. regardless of the computer-or OS host-we are using.

Docker containers can deploy to any machine without any compatibility issues that we need to think of. It will be easier to maintain and deploy an application this way. Think of this as a problem solver, one less problem to think about while making an app.

Containers

Photo by Dominik Lückmann on Unsplash

These containers act like microcomputers, where each of these containers has a specific job and are independent of each other. These containers have their own assigned memory and operating system, making it usable in any place. Why the name containers? Because just like containers, they are independent of each other, easy to stack and if we do not need certain containers we can just get rid of it and not let it board on our ship. Since they are independent of each other, it makes them easier to use. We can run whichever container we choose, and stop the ones we do not use. This makes the process more efficient and flexible, moreover, the usage of one container will not affect the other container’s process. Containers usually run on one specific task such as a MySQL database or a nodeJS application.

darker is a form of virtualization. But unlike virtual machines, the resources are shared directly with the host. Thus, the ability to run several containers at once instead of just a few, like virtual machines.

The journey of docker

first, we make a dockerfile.

A dockerfile is a text documents which contains the instructions on how the docker image would be built.

For example, this is the dockerfile that is used by my team.

This lets the docker image know what to run and what to do. for example in line 17 ‘ RUN apt-gwt -qq update’ means to update the package lists for upgrades for packages that need upgrading, as well as new packages that have just come to the repositories.

Now that we have the dockerfile, we will run this file and by running this file, this means that we are creating the dockerimage since the dockerimage is automatically done.

After doing so, we build the dockerimage by running this command

docker build -t <dockerimagefilename> .

or we can skip this step (writing the dockerfile) and pull the pre-made dockerfiles in different sources.

Then it became a docker image.

Dockerimage

A Docker image is a read-only template that contains a set of instructions for creating a container. After we built the image, check if the image exists by executing command

docker images

see if the dockerimage is listed on the result.

Now that this dockerimage is successfully run, we just need a few more steps!

Photo by Lala Azizli on Unsplash

We need to push the file to our repository.

docker push <username>/<repository>

then after making sure that the file is successfully pushed into the repository, we can use this in our giltab-ci. We only need to add this in the first line

image: <username>/<repository>:latest

this simply means that we point a certain image as the main docker image that we are going to run in this app and we always run the latest update of that repository.

last, to run this on our local we can run this command

docker run <username>/<repository>

And voila! One less problem with docker!

--

--