Hacker News new | ask | show | jobs
by sgt 1484 days ago
Why would you run Docker in a development environment? I know that people do this, but I just can't fathom why. Docker images should be built using a build server and deployed to staging and production. If you have a sane development environment - whether it's a virtualenv in Python or maven based in Java, it's pretty predictable.

I run databases however in Docker on my Mac.

4 comments

The idea is to have the same build pipeline that works locally or in prod. In the end it keeps being an holy grail because dev requirements usually differ from prod requirements (i.e. code hot-reload as fast as possible with interpreted languages in dev vs slimmest possible image in prod).
You can just have multiple stages in the same Dockerfile, one for dev and another for prod, and have your docker compose yml file target the dev one.
Yes, I did exactly this at $DAYJOB, the holy grail for me would be to have the exact same build process without any "if $environment". But anyway I agree it is good enough.
Because as a developer you can simply run `docker-compose up` and have your development environment working immediately without having to ensure you have all the necessary dependencies installed locally.

And even if you think setting up a "sane development environment" is simple, it gets much more complicated as you add additional languages and versions of those languages, and their underlying frameworks, etc. For example if you look at NodeJS alone: we have things like nvm to switch between Node release versions because you'll often have different projects relying on different versions of Node. Or you could just use Docker and it's baked in, basically.

Just because you have a particular workflow doesn't mean other people don't have a different one.

What if someone's dev environment requires a running Redis server, PostgreSQL, and MinIO? And what if you need to keep those instances free of cruft from other projects? Hey, you know what works for that? Docker!

Or what if you need to mock several AWS services locally, because you don't want to be paying for actual AWS or polluting other environments while working on something? Hey, you know what works for that? Docker!

It's easy