Replies: 3 comments 6 replies
-
|
For me, it comes down to two advantages: isolation between processes and reducing dependence on machine state. I think Michael mentioned the first one in the book; it's not perfect, but since each container runs as a separate system, it doesn't have access to other processes or files on the host. There are actually several tools that could get you this feature on Linux, not least creating separate users on the system to run applications, but that brings me to my second point... Using Docker or similar tools means I don't care about the state of the host. I don't need to install shared libraries or any other software that may be different between distros or at different points in time. If I need to reinstall the system because of a crash, I don't need to remember that one random configuration option I changed. All of that gets declaratively specified in the Dockerfile, and the built image can run on any machine with the docker daemon installed. This also makes it easier for one person to set up a Docket image and many other people to run it, without concern for what hardware they're using. Again, there are a number of tools that can help with the problem of state management (not least, Ansible). Docker is basically a different layer of abstraction, and like all abstractions, it's not always useful. But the web dev industry has more-or-less standardized on Docker because of these advantages. |
Beta Was this translation helpful? Give feedback.
-
|
Hi guys, great conversation. Here's my opinion/position and why I am recommending it @wigging If your situation is really very far from it, then maybe skip that angle of the ideas of the book. But I think @bryanwweber has laid it out pretty well. Yes, you will have a lot of docker files, but that is a good thing. Let's consider the alternative, you just install all the apps directly on the server. You REALLY need a series of scripts that codify how to setup your app, db, nginx, etc. on that bare server. You'd run commands such as
You need to save these to files such as a series of .sh files so you know how to do this again in 3 years when you have to or in the worse case the bare server dies. @bryanwweber higlighted it here:
Now with docker, you have basically the same files but named DOCKERFILE rather than SERVER_SETUP.sh. And instead of the above, you have:
To me, this argument of "but I don't want all these files junking things up" just reveals that you are not (but should!!!!) be keeping setup files for your bare server. Whether I put RUN or omit RUN really doesn't change the complexity / overhead. But as Brian pointed out, you get way more portability, isolation, etc. Also, you may have a really simple setup with a single app using a single db with a single version of Python. But will it always stay that way? For example, on the Talk Python server, we have 3 separate copies of PostgreSQL running, one v13, one v15, and one v18 IIRC. We also have MongoDB running. We have multiple versions of Python powering the apps. Yes, technically I could probably install 4 separate database servers on the same machine. But with Docker, I get to set up micro networks / clusters. For example, one of the Postgres servers is for Umami. I can have umami the web app + postgres running and nothing about that will bother/effect/expose the other DBs. Postgres is just listening on the 2 node Docker cluster. How do you make that happen without Docker or something? How do you absolutely ensure that some self hosted thing is safe and can't get to your source? Your prod DB? etc. If there is a vulnerability in Umami and my analytics reporting app gets hacked, will that spread to my source, my api keys via .env files, my prod db data? It might. And I have little visibility / assurances that it won't be possible. All of this goes away with the Docker setup I'm suggesting. Yet, the need for Dockerfiles is really nothing more than writing down the bare metal steps of setup and putting RUN before them. So the complexity is very little in addition. That's the philosophy here. If it doesn't resonate with you, then skip the Docker part. Remove the RUN words and rename the files to setup.sh and you're pretty much good to go. |
Beta Was this translation helpful? Give feedback.
-
|
One bit of follow up @wigging I'm certainly sympathetic to your point of view. I rant Talk Python+ like this for a few years. But each new service, self-hosted thing, etc ratchets up balance in the direction of Docker Compose discussed above. Maybe it's not for you today. But some day probably. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The book talks about the benefits of running many apps on one big server instead of many smaller servers which I completely agree with. It also suggests running each app in a Docker container for isolation. However, this leads to a lot of Dockerfiles and Docker compose files for configuration and network mapping. It also requires knowledge of Docker in addition to Python and other tools. I just don't get the purpose of Docker here; it feels like of lot of unnecessary configuration and clutter. You could make a Bash script(s) to handle deploying and updating all the apps and services. You can use tmux to run each app in its own background session which can also be automated with a Bash script. Everything discussed in the book should work just fine on a single server without Docker. To me, Docker feels like yet another layer of abstraction that just makes things more complicated. The book talks about replacing a bunch of smaller servers with one big server; but those smaller servers have been replaced with Docker containers which still feels like managing a bunch of servers. Can someone help me understand why Docker makes things better on a server because it just makes things more complicated (not easier) whenever I try to use it?
Beta Was this translation helpful? Give feedback.
All reactions