r/AskComputerScience • • Aug 14 '19

Docker

What problem does docker (and containers) solve? And in which projects should it (or not) be used?

Maybe an Eli5 because I made a long research and didn't get an answer yet.

37 Upvotes

17 comments sorted by

View all comments

18

u/corpodop Aug 14 '19

The same type of problem that a virtual machine would solve, but you don't have to carry the whole operating system. in each docker image.

Hence a docker image can be very small, holding just what you need. It lead to faster boot/restart time.

It also allow docker images to be composed out of each other. Let say a docker images for a basic node.js, that you extends to build a image that run your application in production ( basic node + all your adhoc crap ), then you can extends that extension to have a docker image running your integration tests ( basic node + all your adhoc crap + testing framework and test code )

It's also a good way to ensure reproducibility and portability of a environnement. ( your dev env == prod, witch is pretty awesome )

Many use. think of it of a fancy VM on steroid. ( that you can share and re-use, like a library ).

And that the "dev" point of view, if you start thinking about Operations ( OPS ) and things like docker swarm and kubernete, it's a whole lot more of use and application.

It's also a neat tool all around.

7

u/worldDev Aug 14 '19

Also very convenient for consistent testing and building processes on CI runners with minimal work.

2

u/EquationTAKEN Aug 15 '19

Leeching onto the top comment to add:

One thing I also use it for is to not have to install a bunch of things on my machine. If I need to run a Python script, I spin up a container that runs it and shuts itself down. Ruby script, same thing.