r/docker • • Aug 20 '24

When should I use docker

Hello guys !!!

I just ran into à Twitter argument where some people say to use docker 100% because it's easy, portable and when you don't want a container anymore you can delete it in five second.

On other hand, some are bashing docker, saying it has a lot of security failure, container are very different than the original application (alway referencing home assistant) and will cost more resources.

Finally, some say : "use docker on test, real application on prod".

So my question is : " When should I use docker and why ? For a pro ? For a personal use?

Thank you in advance !

3 Upvotes

42 comments sorted by

73

u/[deleted] Aug 20 '24

Docker security failures are rare and quickly patched like most software. It's not some shit project software full of gaping security holes.

Containers are always the SAME as the original application that was built unless you're doing something in your local environment that you're not carrying over to your Docker definitions.

It's incredibly resource conservative. The amount of overhead that goes into spinning up a new container is minuscule compared to running a process native to the host. One thing for sure is that it is far superior to spinning up a new VM with its own kernel in terms of resource usage.

Finally, some say : "use docker on test, real application on prod".

This is the worst take out of all of them that you encountered.

5

u/Front_Ad_2726 Aug 20 '24

Okay thank you for your answer ! Then I will continue using it.

20

u/JackDeaniels Aug 20 '24

The docker on test, real app on prod had me grabbing my head in confusion

11

u/alexgraef Aug 20 '24

"Do the compatibility experiments in production instead of the lab" is a hot take for sure.

10

u/TnYamaneko Aug 20 '24

This is the worst take out of all of them that you encountered.

This is literally the antithesis of what Docker is meant for, who tf uses a different architecture between test and prod when test is meant to be as close to prod as possible to not break it?

0

u/IAMARedPanda Aug 20 '24

Containers builds are not idempotent. Idempotency would require some sort of lock file for installed packages. For example if you update your package manager repository cache in your Dockerfile, there could be an updated version in between two builds.

3

u/moser-sts Aug 21 '24

What? Container builds can be idempotent. It is a matter of pin every dependencies you have. Saying container builds are not idempotent it is the same thing saying CI builds or code builds are not idempotent . It always depends if you lock/pin your dependencies

1

u/IAMARedPanda Aug 21 '24

Can be with effort and time is different than the default. By default they aren't so saying

Containers are always the SAME as the original application that was built

is not accurate.

Also compiled code builds are often not idempotent even if you lock your dependencies which is one of the reasons google made bazel. The only real idempotency for platforms is nix, everything else is flaky even as most OS package managers don't really support the idea that well.

19

u/MaybeLiterally Aug 20 '24

100% of my applications are dockerized.

Certainly Docker has it's fair share of criticism, but so does every other deployment method. Whatever works best for you is what you should do. Along with that, whoever your employer is would also dictate deployment methods as well.

My consulting work has shown me the vast majority of industries are using containers.

2

u/Front_Ad_2726 Aug 20 '24

Thanks for your answer. I also use docker but as a noob, watching this argument made me think that I was wrong using it. You are making me feel good 😁

1

u/[deleted] Aug 21 '24

[removed] — view removed comment

11

u/indomitus1 Aug 20 '24

Love docker. have a ton of apps dockerized.

You can't please everyone in life. Do what suits you

2

u/Front_Ad_2726 Aug 20 '24

Thanks you, great answer!!

7

u/flaming_m0e Aug 20 '24

alway referencing home assistant

In this case they're referring to HAOS vs Home Assistant container.

What they don't realize is that HAOS is running the same exact container/image you can run with a simple docker run. The difference is only in how they're managed. HAOS runs a separate container that coordinates the others. That's why the HAOS instance contains "add-ons" which are merely other docker images that the management container spins up. Here's a secret: you can run all those same docker images as standalone and connect HA to them.

There are very few benefits to running HAOS vs managing your own container stack for home assistant.

I've been running Home Assistant on pure docker for 8 years. HAOS provides me with nothing I can't do myself.

2

u/Front_Ad_2726 Aug 20 '24

Thank you I didn't know HAOS and docker HA were that similar.

2

u/flaming_m0e Aug 20 '24

A lot of people don't realize that they're all running the same container. The difference is merely in the management. That management layer is what gives the appearance of more functionality.

1

u/dierochade Aug 20 '24

I think the native ha install contains a customized os distribution with kernel etc. Technically it’s not just a container for core and another one for “management”.

1

u/flaming_m0e Aug 20 '24

Yes the OS is based on buildroot. It's a minimal OS simply enough to bootstrap Docker.

Everything you interact with is Docker on HAOS

6

u/sk1nT7 Aug 20 '24

The people hating on Docker are most often ignorant and have no deep technical understanding how it works. They do not see the benefit and only feel safe in their bubble of baremetal installs.

Docker, as with any other install option, has its advantages and disadvantages. Though, I am keen to say that containerization is nearly always the way to go.

1

u/Vallamost Aug 23 '24

Definitely is not the way to go for prod databases IMO

4

u/[deleted] Aug 20 '24

If you have a large team, and work on multiple stack, cannot image work without docker.

It has simplified deployment, work environment, library handling, version control, tool versioning etc.

Earlier for a new engineer to onboard to our project it would take 2-3 days, just to setup up the tool chain. Now its just install docker, use the readme file of the project.

Again also depends on ur usecase, if you are developing a gaming application, or a windows application, I do not see how docker can be used. But if your stack is already on linux, move to docker.

4

u/SpongederpSquarefap Aug 20 '24 edited Dec 14 '24

reddit can eat shit

free luigi

6

u/kennethklee Aug 20 '24

It's a tool. use it when you need it.

3

u/PeterHickman Aug 20 '24

For personal use I run services that I need to read rss feeds, download torrents etc without having to worry if they will break if I run a system update. On the machine itself I have had projects stop working when the version of Python or Ruby got upgraded (even a minor version bump). This is the reason I started using docker in the first place. It also allows me to run applications written by other people that have a whole bunch of dependencies that I do not know how to install, Kotlin for example

For work I am developing code for a client that needs to be run on RockyLinux8 on amd64 hardware. I am doing the development work on an M1 Macintosh running RockyLinux8 in an amd64 container. The deployed code runs without issue on the client's hardware 👍

No downsides that I am aware of

2

u/[deleted] Aug 20 '24

I think I haven't read this yet, but I need to be said.

Docker is extremely low on resource overhead on Linux. There are issues on other systems. At least on Intel Macs, there was a virtual machine running in the background for docker and file transfer was done via some slow protocol. I think it was smb.

For windows it was the same with before WSL v2, then it became better and it run in a real Linux environment, but if you mount in local windows file systems rather than WSL2 file systems, you had the same issue again.

That overhead did mean something. But on a linux desktop or on a server? Little reason not to use docker. Even more so, because it simplifies upgrade, deploy and everything else.

To be fair, if you run something that needs access to your GPU or other hardware support, while not impossible, it makes the whole thing harder. And if you use the whole server for only one thing, I get why you decide against it.

But those are rare cases and in general, containers are the better option. About security. Yeah, docker escapes are a thing and docker is often run in privileged mode, so you escape into privileged mode again. I get it. But on the other hand, it also is great in isolation your processes. So, up and downsides. And privilege escalations are a thing on bare metal as well.

2

u/[deleted] Aug 20 '24

As someone who runs thousands of containers in production you can tell your friend "Hi" from me 😉. I would never run anything not in a container anymore.

2

u/jillesca Aug 20 '24

I have a static web site serve in cloudflare, I don't need docker there. When i want repetitive builds, I will use docker (which is most of the time). If I want to use wasm components, i would use wasm. It depends on what you are trying to do. But 99% i would use docker, it makes development easier

2

u/[deleted] Aug 20 '24

Honestly I wouldn't be worried about security, I'd be worried about efficiency. Containerizing applications can add a lot of overhead, and a good amount of the time people don't really need its advantages- just think "what would be wrong with installing this like a normal application?"

Containers are nice for quite a few situations though:

  • it's super ez to make elastic scaling applications by deploying Docker containers with a load balancer

  • If you're not really sure what host machine your application is going to run on and need that portability and compatibility

  • If it gets you out of the overhead of using an entire VM

Reasons people use containers that aren't really optimal:

  • To say you used Docker. I know new tech is exciting, but don't get ahead of yourself.

  • Managing dependencies with npm, pip, etc. Your dev environment should already be tracking and isolating these, don't make it Docker's job

  • Using Docker images you don't understand for difficult to configure services. If you can't figure out how to deploy this application normally, and are depending on other people's Docker images, that's a problem and you need to more thoroughly understand what you're doing.

  • Putting yourself in tech debt. You can set up clusters of microservices with existing images really quickly, but this tends to result in suboptimal sprawl and wasted compute resources.

  • Making things scale that don't really need to scale. This is more about cloud type stuff, but that dashboard you made for a few stakeholders to look at probably doesn't need to scale up to thousands of users.

1

u/LookingWide Aug 20 '24

Any tool should be used where it solves more problems than it creates new ones. For example, if I need to run a single application on a VDS, then I see no point in adding Docker. But there are many situations where I can’t do without it (or Podman).

1

u/Canonip Aug 20 '24

I have pretty much everything containerized.

Except a home assistant os vm (which uses docker itself) and non-linux os

1

u/ohcibi Aug 20 '24

You should use docker when it makes sense. Which is whenever you want to use a tool or deploy an app (ie both in production and development environments) that comes along with all its dependencies. Similar but not equal to a flatpak. So I say this argument you had was an argument with people as clueless as you are yourself, which is common for twitter. If you haven’t deleted twitter yet, delete it now.

1

u/TechaNima Aug 20 '24

Everything I run is a docker container. It's the best thing ever and I don't see a reason why I would run something on the host directly. Just install Portainer to manage it all and enjoy hassle free containers.

1

u/EidolonAI Aug 22 '24

I think this os a fair question and shouldn't be downvoted. Containerized environments solve a lot of problems. I'm not crazy old, but remember the crazy script pipelines needed before hand, and how hard it was to keep environments functional between different types of machines. Prod never ran like my local machine, and my local machine only sometimes ran like the QA's.

The infrastructure around containerized runtimes has really a great step for the industry.

1

u/Away_Nectarine_4265 Aug 22 '24

Docker is life saver if you have tons of dependencies.

1

u/isThisRight-- Aug 22 '24

Whenever you want.

1

u/[deleted] Aug 23 '24

Docker is my favorite dev tool bar none

1

u/ServerStream Aug 23 '24

Docker is great for auto deploying apps as well, you can setup GitHub actions to deploy or update your app. Also docker has something called swarm mode where you can connect multiple servers together, this is extremely useful if you use Traefik for load balancing and web based apps.

1

u/cloud-strife19842 Aug 23 '24

Don’t Docker when you hardly know her!

1

u/ChangeUsual2209 Aug 24 '24

Develop on docker, deploy on docker? It's quite safe, unless you don't have really huge monolith applications. Then docker is only for twitching with varsions of software it use