r/AskProgramming • • Jun 12 '20

Why is docker a thing?

I'm genuinely curious here, not trying to ask a loaded question, is just that... I don't really understand why is so widespread, so I'll just go with my particular case:

I'm on $Big_Corp. We have many stuff obviously standardized, and for our web applications we have been told to use a dockerized database. I started a small project from scratch and to connect to a $Standard_Database I just downloaded $Standard_Database, installed it on my machine, configured it and began working with it.

Of course, this is on a development environment, so more or less, who cares how I got this set up, but I'm approaching a point in which I got to "get real" with the database, which implies setting up a docker image of $Standard_Database.

Now, for what I've seen and I'm reading, this is just some kind of container that will (in theory) only have that database, with docker itself running in memory for I don't really understand what. From the point of my application and my database-access program, I will only have to change the database connection info and I would be good to go.

I kind of understand a potential need for having independent systems and all that, but, as someone who really love continuous integration and has spent lot of time making processes that deploy cleanly, I don't really see the point on making a new layer just to have this database for this application.

Maybe I'm having here a too narrow view and in a bigger org is needed to keep things tidy (thus my case of use would be just "the way corporate has told us to do things", maybe I'm missing something here. And thus, I'm asking here about it.

53 Upvotes

30 comments sorted by

View all comments

4

u/sbcretro Jun 12 '20

Docker + k8s enables on the fly, fully automated scaling. The ability to turn shit off when you don't need it is absolutely necessary for heavy duty services running in the cloud - you get high availability, but you only get (AND PAY FOR) EXACTLY what you need. You did that super bowl advertisement and are getting 1000% more traffic? Your infrastructure doesn't crumble (assuming you are using it correctly). It's off hours on a slow day and requests are almost non-existent? That shit can scale back down. And this happens within parameters (minimums, maximums, rules for when new instances get spun up) that you define.

With Docker and k8s, domains can easily break apart your services for security's sake. ALL your configuration for re-deploying your entire organization's infrastructure can be managed with scripts, which are just code that can be in version control with audit trails.

On the desktop, developers can work inside docker containers that have standard environments set up. A desktop tech can set up the software you need for a specific project, then that project's architect can dump a few configuration files (or more likely the desktop tech dumps the ones needed for that particular project that were created by the archetect), and you have a dev environment guaranteed to have exactly everything you need when working on said project even if your laptop takes a dump. No sitting through installer after installer, and no need to even run a full blown VM if the host OS supports the container type.

There is also all sorts of automated CI/CD that you can do as well, including spinning up temporary test environments when needed for security or load testing, or even just clean slates for running automation against.

Most of that is k8s AND docker, but that's where a lot of the power is. Even just Docker itself is useful for segregating services without requiring a full on, separate virtual machine.

Do you remember the old unix tool chroot? It's still used to this day when bootstrapping linux. A container is like a chroot environment, where exactly the needed files are hard-linked into the chroot folder, and the whole thing lives in its own little image file.

1

u/Neuromante Jun 12 '20

Huh, never ran into problems regarding scaling (this was usually the problem of other department), and I'm seeing myself having to care about this in the future. Care to share any article on the topic?

1

u/flagbearer223 Jun 13 '20

The super cool thing about docker & k8s is that it turns configuring servers and infrastructure into pure programming (for the most part). It means that it no longer has to become a problem of the other department - your programming skills directly apply to building out Dockerfiles and k8s infrastructure definitions. Once you get over the hump of figuring out how to use them in a meaningful way, you no longer have a wall between operating the software and developing the software - you can do both :D