Welcome dear reader to yet another learning opportunity. I applaud you for the commitment devoted to become a better version of yourself. Always here to remind you,
Every master was once a beginner
Whatever tech stack you choose to follow, do not underestimate the small beginnings!Stick to it!
Since we started this learning journey together, we have looked at a few principles and mastered some techniques, absolutely beginner level. Some of these have been;
Introduction to Python Functions
Feel free to check them out.
Diving right in …
We are getting started with our topic for the day. Hope you are refreshed and have a clear mind. This article assumes no prior experience with Docker or any of the terms used, sit back, read along and enjoy.
To explain what Docker is, we will first dig a few decades back before the docker world. Problem scenarios will be used to understand how docker came about, why it is important in your software development work flow, and basic usage examples.
The Problems before docker.
Scenario 1
You have just landed your first tech developer job, before anytime elapses, your very first assignment rolls in from the Chief Technical Officer.
The assignment...
You are required to develop an application for a very needy segment of the population, the blind!!.
How you start, lets see!!
From your expertise, basing on the app requirements, you decide on a set of tools that will enable you complete the task before hand.
Your application say will require these dependencies to run;
- An operating system
- Python
- A database like Postgres
- Flask
Installing app dependencies manually
Task before hand is installing all these tools to your local system. Phew!!! That looks tiresome already. Remember while installing them manually, you are only getting versions specific to your machine/laptop.
Coding, collaborations, testing
So until now, you are very comfortable coding the real-world application that solves a pressing need in your community.
Your boss has given you a deadline to complete the first module of the application. Yikes!!! Deadline day is here and the module is complete. You send the code over to the operations team, to test the application.
A few days later ...
Operations Team manager
:
Hey, The code you sent me cannot run on my system, no app!!
A big problem arises
Can you see it?
Why did that happen? Well simply put, you used dependencies specific to your personal system, not universal. Another developer to test out your application will also need to manually install these dependencies on his personal system, and the chain continues that way. Along the way, there are more chances of your app breaking,....Oh no!!!
Scenario 2
You have built out your first application, but would like to test it out using a different operating system. How do you go about that?
After making some consultations from your workmates, news has it that its very possible through Virtual Machines
.
Hurray, you feel great utilizing the concept of Virtualization!!
Virtualization has greatly aided developers in their ability to construct and produce from their computers as if they were separate platforms. They can use virtual computers to construct completely virtual operating systems in which to operate and build.
A developer can run a virtual Windows computer on their Macbook to evaluate the operation of a Windows-constructed application. Running a virtual machine is more cheaper and easier than buying a brand new one. I guess it's a really great option saving you a couple of thousand dollars.
Look at the difference between Docker and Virtual Machines from the illustration below.
Problems arising ...
As you enjoy trying out different virtual machines on your local device, you start noticing a few hiccups arising. These could be and not limited to;
- Exhaustion of computing resources like ram, storage
- Network congestion
- Marginal app performance inside the Virtual machine
With the virtual machines installed, they share the same hardware resources with your normal operating system. So the issue of scalability arises since your virtual machine keeps expanding but not your hardware performance.
Do you notice that problem now?
Leaving problems alone...
There are quite a number of scenarios to list out in regards to traditional Software development practices. But I just highlighted on a few to whet our appetite and understand how Docker
comes in the picture. Having understood those challenges, am sure your mind is sparked to solution mode already.
Let us refocus
Who comes to our rescue? Docker !!!
What is Docker?
Docker is a computer program that accelerates the way you build, share and run modern applications. Essentially it solves all the problem scenarios we have discussed above.
Docker takes away tedious, monotonous configuration procedures and is utilized across the development lifecycle for quick, simple and portable application development both on desktop and cloud.
In other words, while you use docker development becomes more efficient and predictable.
Docker is a tool for building, running, and deploying containerized applications. An application's code, libraries, tools, dependencies, and other files are all contained in a Docker image. When a user executes an image, it might turn into one or more containers.
How Specifically?
Okay to answer this question, I will split the concept into 3 ways;
- Build
- Share
- Run
Build
Everything in Docker is based on images and containers.
A Docker image is a file that a Docker container uses to run programs. Docker images, like a template, serve as a collection of instructions for constructing a Docker container. When utilizing Docker, Docker images also serve as a starting point. In virtual machine (VM) settings, an image is similar to a snapshot.
Docker images include several layers, each of which is derived from the one before it but differs from it. The layers reduce disk use while boosting reusability and speeding up Docker builds. Image layers are read-only files as well. A written layer is put on top of the unchangeable images once a container is formed, enabling a user to make modifications.
Official images are those created by Docker, and community images are those created by Docker users. Docker applications are monitored by the CoScale agent, which is an official Docker image.
With confidence, leverage Images from the Docker Hub image repository that are Docker verified and official. As a basis for your application development, use these reliable and secure images.
Code, config files, environment variables, libraries, and runtimes are all included in a Docker image for running a containerized application. The image may be run as a Docker container once it has been deployed to a Docker environment. Docker run builds a container based on a specified image.
In simple terms, you build your image that contains all the libraries, and dependencies for your app and upon running that image you generate a container which is an instance of your application. You can make multiple versions of your application.
For example;
You can build an image for your flask project based on ;
- Python
- Flask
- MySQL
When you run that image you create an instance of your application which you can share to anyone and will run without any issues.
Do you see how much Docker saves you!!
Share
Once you have built your image you are able to share it to the world and anyone can use it (if you choose to).
You may deploy containers and test and share images from private or public repositories, such as those in the Docker Hub cloud registry service. Image management and access control are also available through Docker Hub's Docker Trusted Registry.
Users may use the docker push command to publish custom images to the Docker Hub and generate new images from existing ones. Docker offers comments to authors prior to publication to ensure the quality of community images. The author is responsible for updating the image once it has been published.
With Docker it is easy to collaborate with team members and other developers to come up with new ideas, and simply upload images to Docker Hub. It is even possible to have roles-based access control and Docker Hub Audit Logs. That makes it easier customize developer access to images and gain insight into activity history.
Run
Remember we said that when you run the docker run
command, you are making an instance of your application. You can make as many instances as you like, for example:
- Instance for development
- Instance for testing
- Instance for staging
- Instance for production (One being used by application users)
So the concept is to deliver numerous apps with ease, and have them operate the same way in all of your settings - desktop or cloud-native - including design, testing, staging, and production.
How do we do that?
It is really simple, Deploy your applications in separate containers independently and in different languages. Reduce the risk of conflict between languages, libraries or frameworks.
Using the ease of Docker Compose CLI, you can deploy your apps locally and in the cloud with AWS ECS, Azure ACI, and Google GKS with just one command.
Yes!!! That is it about Docker. Hope you have learnt some concepts about what Docker is?
Getting Started Guide.
Docker is a really great tool to include in your software development workflow.
To have a more whetting experience about docker, please refer to the guide.
Without installing Docker on your system, you can leverage the online play ground and practice how to use Docker Images and containers.
Congratulations upon finishing the article. I trust that you have learnt something.
How was the article?
I love learning with the friends I share content with. Are there any insights you have about the article? Any additional features/concepts that would have been of real value to the article? Whatever it is, please share in the discussion section.
For now... I tap out. Enjoy yourself and see you next time.
Top comments (5)
Such a great and easy-to-understand article. Explanation was quite simple. Thanks. So basically we can say that Docker allows to ensure consistent environment for our apps across different systems, right?
Yes! Glad you understood the concept. Yes Docker ensures that consistency quite well.
Hello kubona Martin Yafesi,
thanks for your article.
I've heard of docker many times, but this is the first time I've read about it.
Your article helped me understand docker better.
Hello Akin C,
Thanks for taking out time to read the article,
Am glad you understood the concept.
I red alot over Docker, but this is the first time that I understand how Docker actually works. The world needs more explainers like you simplifying everything. Thank you very much.