DEV Community

Carlos Armando Marcano Vargas
Carlos Armando Marcano Vargas

Posted on • Originally published at carlosmv.hashnode.dev on

What is Docker?

DISCLAIMER: This is a short article about exploring Docker and some of its basic concepts, not a comprehensive guide or tutorial.

Since I started learning to code I have heard about Docker.

I thought it was just a tool big corporations use, and maybe some startups, but a regular person like me doesn't. And it doesn't matter, because, I just run my apps on my machine without problems, like everyone else. I was wrong.

I have found that a lot of open-source projects use Docker. A lot of jobs list Docker knowledge as a requirement. But why? Why learning Docker is important?

And first of all, what is Docker?

Docker

What the documentation says about Docker:

Docker provides the ability to package and run an application in a loosely isolated environment called a container. The isolation and security allow you to run many containers simultaneously on a given host. Containers are lightweight and contain everything needed to run the application, so you do not need to rely on what is currently installed on the host. You can easily share containers while you work, and be sure that everyone you share with gets the same container that works in the same way.

Also, the documentation describes the following scenarios:

  • Developers write code locally and share their work with their colleagues using Docker containers.

  • They use Docker to push their applications into a test environment and execute automated and manual tests.

  • When developers find bugs, they can fix them in the development environment and redeploy them to the test environment for testing and validation.

  • When testing is complete, getting the fix to the customer is as simple as pushing the updated image to the production environment.

The first time I read this, I was confused. I thought I was able to do all of that without Docker. Especially the part of writing code locally and sharing it with my colleagues.

I was wrong. It is not impossible, but there are issues. If I develop a Django application on my laptop, it has Windows 11 as OS, and Python 3.11. Then I shared it with a colleague, who has a laptop with a different version of Python or a different OS (Different Windows, Mac, or a Linux Distro). Probably my application will not run. Because it is a different environment.

I thought it was possible to develop an application and run it everywhere. But this has been a long-time issue in software development.

So, Docker builds a container to isolate the application from the environment, so we can develop our application and increase the chances to run it everywhere.

What is a container? The first time I heard this term, I immediately relate it to this:

Imagine we want a fish as a pet. We buy a fish or trap one in the ocean. But we don't grab it with our hands and take it to our home. We put it in a fish tank with water in it, which is a container. We are taking the fish from its environment, and if we want the fish lives, we have to provide it with a similar environment.

Oversimplifying, Docker does something similar for our applications. It builds a container with everything our application needs to run, no matter the environment it was developed.

Dockerfile

A Dockerfile is a text document where we write all the commands we possibly call on the command line to assemble an image.

Continuing with our fish and fish tank analogy. Imagine a Dockerfile is like instructions for building a blueprint for a fish tank.

Docker Image

According to Docker documentation:

An image is a read-only template with instructions for creating a Docker container.

A Docker image is like a blueprint, we can create multiple containers from an image.

And finally, this is what the documentation says about what a container is:

A container is a runnable instance of an image.

A container is defined by its image as well as any configuration options you provide to it when you create or start it.

Conclusion

Docker and containers in general solve an issue that I don't have any idea how many problems cause in the past. I do know containers make it possible that right now we can build an app and deploy it easily.

Thank you for taking the time to read this article.

If you have any recommendations about other packages, architectures, how to improve my code, my English, or anything; please leave a comment or contact me through Twitter, or LinkedIn.

References

Docker overview

Dockerfile Reference

Docker for absolute beginners what is Docker and how to use it (+ examples)

Docker for absolute beginners: the difference between an image and a container.

Top comments (0)