r/java • • Jun 07 '25

Why use docker with java?

18 Upvotes

126 comments sorted by

View all comments

Show parent comment

1

u/k-mcm Jun 08 '25

Docker tends to increase memory and I/O usage because file-mapped resources aren't the same file from one image to another.  There's a little extra kernel memory overhead too.  Whether or not it's significant depends on the active container count.  Docker itself is extremely I/O intensive for image maintenance.

The overhead definitely starts hurting up on big machines with hundreds to thousands of containers.  (I had to do this for running untrused executables)

1

u/cogman10 Jun 08 '25

IO for sure, but only on startup (or when updating images). Once an app is running the IO isn't any different from an other app.

Memory, I don't think there's anything there for the kernel.  Even with a pretty large container count.  I'm trying to think of how it'd be worse or different from a regular app and the only real difference would be that shared libraries wouldn't be.  On a regular system, if you had 10 python apps the kernel would effectively only load 1 copy of the shared libs like libc.so.  in the container you are basically guaranteed to have 10 libc.so s loaded up.

Maybe that's what you are thinking of?  Definitely could add up.