Defining Docker 🐳 – DEV Community 👩‍💻👨‍💻

September 6, 2022

This article will cover the introduction, basics, and usage of Docker. We will be walking through the concept of containerization. Let’s get started!

The definition as per Wikipedia:

Docker is a set of platform as a service (PaaS) products that use OS-level virtualisation to deliver software in packages called containers

*Swuusshh *over the head am I right? 😂
Let me clear that for you, Docker is a tool that ensures your project can run on any computer in the world. It makes sharing of projects easier.
Before we get a deep dive into Docker, let’s understand why you should learn Docker.

  • It is pretty much the industry standard now.
  • Helps you share your projects easily.
  • It’s easier to collaborate on projects.
  • Say as a Frontend engineer you need a SQL DB, Docker makes the process easier.
  • 🐘 in the room, Yes SDEs are also required to use Docker!

Moving ahead I believe it will be a skill just as essential as git in the Software Development Life Cycle. Docker will help you irrespective of the domain you work in.
Enough with theory let’s first learn how to install Docker.

There is nothing better than the actual documentation of Docker for the installation : Here
You can install it on any Linux Distro, MacOS, and even on Windows via WSL. As per my advice, if you are interested in learning Docker, you might want to learn Linux by ditching Windows for a while.
Docker Desktop is a real lifesaver for beginners, but moving ahead I would encourage you to learn the CLI commands for the same.

There are basically three things you want to learn to get an understanding of Docker.

  • DockerFile
  • Docker Images
  • Docker Containers

(There are more concepts that we will be covering in another article.)

Let me explain the concept, bear with me for a while.
When I give two people the lyrics to a song. Both of them will sing the same song, but will sound different, right?

Suppose we created an mp3 file 🎶 of the song and then send it to these folks. There won’t be any difference in how it plays and sounds.

That is the concept behind Docker in simple words.

Image description

Coming to the steps:

1. Writing the DockerFile

DockerFile is the lyrics to any song.
You start with describing the base image (say the OS you want your project to running be on). Moving ahead you explain and mention the steps to run your project on that OS.
You can learn about writing DockerFile for your project from Here. I would encourage you to explore the Youtube Channel of TechWorld-with-Nana. I have learned a lot from her channel.

2. Creating Docker Images

This is the moment of truth for your Dockerfile. Say it would be the compilation step of your code. It is the mp3 file of the song.
Go to the location of your docker file in the terminal.

docker build .
Enter fullscreen modeExit fullscreen mode

There are multiple options in this command as well. Explore them Here
This image that you built is the one you will be sharing with others. You can do that using DockerHub or any other container registry.
There are other steps to share (push) your image to some registry Here
Make sure you have the right access before making any push.

3. Running the Container

A container is a bigger topic in itself. Maybe I will be writing an article on it later. Now, we will discuss how to start and run a container. If you use Docker Desktop it becomes easier and more convenient for a beginner.
For the CLI, execute

docker run <docker-image-name>
Enter fullscreen modeExit fullscreen mode

You can explore more on the run command Here.
There are multiple options to play around with and learn about. You can even open a terminal session of a running container.

So you have understood the concept of Docker. But now you want to implement and practice it. Let’s be honest, theory without application is just a story. There are various ways to implement Docker that I know, I will keep this list updated.

  • Docker Labs: This is a playground lab to learn and implement Docker concepts. To my surprise, most companies have labs/playgrounds to help beginners get started with their products. Explore more Here
  • Learn on the Go: This is an approach I prefer to learn anything. I pick up a project and learn the implementation while building it. I would suggest you dockerize all of your existing projects first.
  • KodeKloud: It is one of the best places to learn and implement basically any DevOps tool or skill out there.
    Start learning: Here

I hope you have got a basic understanding of Docker. There are plenty of resources out there, even better than this. My intention with this article was to break down the basics to you in the most simple format I can. I had a different approach to understanding Docker, which I wanted to share.
Reach out to me on Twitter for more such content Kitarp29
Thanks for reading my article 🙂

Source link

Comments 0

Leave a Reply

Your email address will not be published. Required fields are marked *