Hii.. thanks for stopping by. What you will find in this post:
- What is docker? What does it solve?
- Why should you know about docker?
- Three ways in which you can start using docker every day.
- Why you should learn docker and have it in your dev toolbox.
Before we come to what's in this for you as an individual, a quick introduction to docker, and the problem it's trying to solve:
Docker is a software platform for building applications based on containers — small and lightweight execution environments that make shared use of the operating system kernel but otherwise run in isolation from one another.
Four phases from the above sentence sum it well. Docker provides a:
- small and lightweight
- execution environment
- based on "containers"
What does this mean? It means that with docker you can package your application, along with the environment to run it.
Why is this a big deal? Because before containers, people used to just share the application binary. When Jenna sends Ria a program that she wrote and compiled, this is what might happen before docker:
It didn't happen just between the developer and QA, but it was happening everywhere. QA tested the program, but when he deployed the program into production it broke because... for example, he had
node v12 on his test system, while in production they were still on
Or maybe you wrote your awesome code on a Mac OSX 11.3 but someone wants to run it on his Ubuntu 18.04 where node is not even installed. Bleh.
Yuck. It was a total mess! And the solution? Package the program as well and the environment together. And thus was born containers.
You can package your application along with all its dependencies into a docker container.
Now you might be telling, "Hey, I am good without docker because I don't have these sort of problems to deal with".
Hmm. Not really, buddy. People have already packaged a lot of applications as Docker images and have made them publicly available. So you can use docker to grab and use any software when required.
These are some ways in which you can take advantage of docker to boost your own developer productivity. These are three ways in which I leverage docker.
I'm just making this up, say one fine morning, someone comes to you and says that you need to install and run a new type of database named "FoobarDB" on your laptop... now that you know about docker, you just go to google and type "foobardb docker". You do get the docker image name, and then type in:
docker run foobardb
That's it. FoobarDB is up and running on your machine. How awesome is that?
What if you want to run multiple versions of the same DB at the same time. Fret not,
docker run foobardb:6.2
docker run foobardb:3.2
docker run foobardb:8.2
I mostly use it to run databases, so for example, if you want to run Postgres:
Almost anything you need for development is available through 100s of images, created either by official maintainers or the community.
Here is the Postgres image on DockerHub. Instructions and different configurations for the images are available along with it on DockerHub.
Now that you know about this, next time you are looking at different ways of installing software, take the docker route if they provide docker images:
I am a Linux lover but have to use a MacBook at work. There are things that I like to do from a linux shell, so I have a ubuntu image running:
docker run -d --name myubuntu ubuntu
This is where "lightweight" and "environment" helps...
You get the full ubuntu "environment", but since it's just an environment, it's lightweight, you get the entire OS feel, and it takes under 5MB when not being used!
To summarise, docker is awesome, I wanted to cover the absolute basic usage of Docker in this post. It's highly recommended that you start using it, there are a lot of other advanced things that you can do to achieve it.
- No software needs to be installed locally. So the system is clean.
- You can run multiple version of the same software.
- You can delete the container and start fresh anytime.
- Dependencies for any software is packaged along with it.
- Docker is production-ready software.
- There are hundreds of public images available for almost anything that you need for software development.
- Docker images/containers are platform-independent. So you can generate a docker image/container on a Linux machine and run it on windows/mac / any other os supported by docker.
I'd love to know in the comments about other ways you've seen docker being used to improving dev productivity. Thanks for reading. :)
I do 1-1 mentoring for young developers, you can book a slot here if you are interested.