TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Do you use a dev container and why?

14 pointsby backslash_16over 2 years ago
I&#x27;ve never really worked with containers in my professional career and I&#x27;m learning about them now.<p>It&#x27;s hard to tell from reading online if people are using them for their dev environments or if they&#x27;re developing on their host (or native, whatever you want to call it) and using a container to package the application after its built.<p>What do you use containers for? Do you setup your dev environment in a container, and if you do, I&#x27;ve got tons of questions.<p>- Do you do it for every language? - Do you install your static analysis and other tools in the container? - Do you debuggers work (Visual Studio, gdb, pdb, whatever)<p>If you use a container for only your post-development workflow do you ever use separate containers for build and test vs the final packaged application?

10 comments

KronisLVover 2 years ago
It depends.<p>In certain stacks that can be relatively &quot;self-contained&quot;, like Java, where you just need a version of JDK, it can be easier to just install it on the system and run&#x2F;debug&#x2F;develop your application locally, even if you can deliver it inside of containers. Why? Because remote debugging can be a bit of a bother to setup (in any stack) and sometimes the IDE integration works better without containers, provided that you actually embrace coupling your development process to the IDE.<p>In other stacks that would be more complicated to setup, like PHP, it can be better to run even your local environment inside of a container, bind mounting any of the files that you need into it and working that way. If done correctly (e.g. you don&#x27;t suffer too much because of file permissions, should your host OS use NTFS), it can be similarly easy to the Java example, though remote debugging setup will be a must.<p>As for other complicated pieces of software, like databases (MySQL&#x2F;MariaDB, PostgreSQL and so on) or object storage (MinIO&#x2F;Zenko, or another solution that&#x27;s similar to S3), key-value stores (for example, Redis or memcached and so on), it&#x27;s almost always going to be better to run them in containers.<p>It&#x27;s not so cut and dry, though, because all of the software that you don&#x27;t need to develop&#x2F;debug but just need running locally can also run in containers with no issues. The problems start when you try doing something fancy - like wanting to run the applications you&#x27;re developing locally with Skaffold and rebuilding them on code changes, which in practice will be slower and more resource intensive than doing that natively on the system.<p>Of course, what&#x27;s true for me and my projects, might not be true for someone else.
评论 #33517407 未加载
dgnemoover 2 years ago
&gt; people are using them for their dev environments [?]<p>Yes, we use a container for dev environment so that we can share the same env across all the team. If it&#x27;s decided that we need 1 more tool in our toolbox, the script that generates the container is updated (the script is version controlled in the repo too), the CI&#x2F;CD generates a new container version, all the devs can now use the same NEW environment.<p>We actually use the container as image for (remote) virtual machines, so we don&#x27;t really compose multiple containers.<p>The container has all the tools (for several languages) that we use as a team.<p>IDEs and debuggers can connect through ssh.<p>&gt; post-development workflow do you ever use separate containers for build and test?<p>We build different flavors of the final packaged application, for example:<p>- production flavor: uses a minimal, nonroot container base image (see: <a href="https:&#x2F;&#x2F;github.com&#x2F;GoogleContainerTools&#x2F;distroless" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;GoogleContainerTools&#x2F;distroless</a>)<p>- debug flavor: includes few extra debug tools inside the container
flippinburgersover 2 years ago
Docker is very convenient when it comes to maintaining uniformity across different developers machines. Once the boilerplate is done, &#x27;docker compose&#x27; will stand up complex projects in a matter of minutes (depending in machine&#x2F;internet speeds). Every startup that I have worked at uses docker and, honestly, I would question why one wouldn&#x27;t want to use it.<p>Most of my work has involved rails or golang. Live debugging of go isn&#x27;t really a thing. Rails on the other hand is usually done via a gem where you manually type in breakpoints and go from there. Regardless, it all works in containers.<p>Keep in mind that depending on your OS and docker setup, you can just have your container read files from your local filesystem. So edits are immediately reflected in your container and you don&#x27;t need to build a new one when making changes. It is pretty flexible.
评论 #33519087 未加载
necovekover 2 years ago
A trend is to move towards using containers to replicate most of your production environment in your dev environment.<p>This has a bunch of purported benefits (you maintain one way to run your app, you test all the deps while developing), but note that it&#x27;s never exactly the same setup.<p>It also has a bunch of issues like performance (in a large team, images change often, which means redownloading image layers or entire images; starting up containers adds an overhead too, especially noticable with running unit tests), flexibility (unless you run a full cluster locally, it&#x27;s usually harder to work on multiple branches of your software at the same time since containers would be configured to use the same internet ports) and complexity.<p>I think an ideal would be containers for local dev work without tying them to production images so they can be optimized for different goal, but I&#x27;ve never seen that. The big issue there is that Dockerfiles are not composable (ie you can&#x27;t have a install-deps sub Dockerfile that follows the caching semantics).
评论 #33516966 未加载
danweeover 2 years ago
At work I use whatever my team uses. For personal&#x2F;side projects I tend to use either a VM or a Docker container for dev purposes. The main reasons are:<p>- a bit more of security. If I download a third-party dependency and it turns out that it executes `rm -rf &#x2F;` in the background, well, only my container will result destroyed and not my personal machine. For serious malware, well, I guess it doesn&#x27;t matter if I use containers (but I&#x27;m less concerned about this because being that paranoid would make my side projects feel like work)<p>- all the tooling gets installed in the VM&#x2F;container, so my personal machine doesn&#x27;t get polluted with gdb, pdb, compilers, linters, modules, packages, etc.<p>- I have a Mac, so I usually work on Linux VMs&#x2F;containers
2rsfover 2 years ago
Just use it if you find the need and it&#x27;s the right tool for the job at hand.<p>As a tester I use containers for setting up clean test environments, when writing code I use it to get the latest and greatest dev environment from a common depot and on CI platforms it is useful to get all the tools and environment you need setup for you.<p>It works for every language, some are easier to set up than others though, I never got a debugger to work in a container but never had the need to.<p>It&#x27;s best to use the same image for dev test and prod, but not the same running container.
viraptorover 2 years ago
&gt; dev environments or if they&#x27;re developing on their host<p>It&#x27;s usable for both. Some people go one way some the other. It definitely makes developing in a container on a mac easier if you don&#x27;t have to worry about compatibility with the target environment.<p>&gt; If you use a container for only your post-development workflow do you ever use separate containers for build and test vs the final packaged application?<p>Yes, most of the time, mostly because the tests require extra dependencies which are not needed in prod.
评论 #33515995 未加载
PaulHouleover 2 years ago
I&#x27;ve often been behind a slow internet connection for which downloading container images can add hours of waiting to my day so I &quot;just say no&quot;.
aitchnyuover 2 years ago
I tried it for a toy project in Python and Jetbrains Pycharm supported python installation (completion, navigation of libraries) within container perfectly. Then I moved to VS Code, installed a few extensions but it didnt work at all.
MonaroVXRover 2 years ago
A whole virtualmachine and I can make snapshots and transfer it to another machine!