Live data from Hacker News

Developing with Docker

danielquinn.org

61–66 of 66 posts

Re: Developing with Docker

#61

Earlier quoted context omitted.

> I don't want to be negative, but if one of my engineers came to me saying they wanted to deploy images built from their machine, with all the dev niceties enabled, to go to prod, rather than proper CI/CD of prod optimized images, I'd have a hard time being sold on that. ditto, "worked on local" is a meme for a reason.

but "works on my machine" is exactly the problem docker solves -- if you still have those issues then you're not building your images right

That's why there is the meme. Docker doesn't always solve this, or even often on its own. You can't just "build image to docker" and expect things to go okay and pretend you can be agnostic about its prod environment (you kind of can, but usually requires an ops team supporting whatever assumptions your image made).

It's been addressed in other comments but you have:

- differences in architectures, CPU, memory

- if the docker image has a volume attached, unless local perfectly represents prod, you're going to have issues

- networking and firewall rules can be drastically different than a production environment and the assumptions made there

- differences in RBAC/IAM/etc. between local and prod could go on and on.

In reality, this is a nice idea, in practicality, it almost never works 1:1. The common refrain is "well just make the local/dev/sandbox exactly match prod" and my point is this is often unrealistic to the point it cannot/won't happen. If you can do it, good for you, I just personally have never seen this work as simply the author describes it in a system of any kind of complexity.

Re: Developing with Docker

#62
post #59

> At it's simplest, stuff like this: if ENVIRONMENT == "prod": do_something_only_production_does() ...shouldn't happen. This is a common refrain among people that IMO do not have a lot of experience in big, complex systems, especially ones running a lot of legacy code. Like, ideally, sure, but in reality making this possible almost always involves extra cost, time, and complexity, and what do you gain from that, real…

The Django equivilent is having different settings for prod vs dev, and for good reason: There are things I run in Dev, like the Django Debug Toolbar that I just wouldn't run in prod.

Fintech is laden with stuff like this. Often test environments vary drastically from prod by necessity, or due to compliance and regulation, things need to be done very differently in a production environment.

Re: Developing with Docker

#63
> What if running the linters was as easy as:

> $ docker compose exec web /scripts/run-linters

What do people do for making these kinds of commands less verbose and easy to remember?

We've done things like use Makefile with the above behind `make lint`. However, chaining together shortcuts like "make format lint test" gets slow because "docker compose" for each one takes time to start up.

If you instead run the Makefile while you have a terminal open inside one of the Docker containers, that can be faster as you can skip the "docker compose" step, but then not every Makefile target will be runnable inside a Docker container (like a target to rebuild the Docker image), so you have to awkwardly jump between terminals that are inside/outside the Docker container for different tasks? Any tricks here?

Re: Developing with Docker

#64
It seems I do the opposite of many commenters.

I do not run Docker in production at all but I also do not develop any serious projects outside of Docker.

Installed on the host machine are only VSCode, Docker and Git.

You work on a project by cloning it, opening in VSCode and clicking on "Reopen in container".

This will spin up generic services like databases and then the actual app container as a VSCode Remote Container, with all the development tooling inside the container.

Does not matter if tooling changes between projects, any project can be worked on with a single click of "Reopen in container".

Host machine stays clean.

Re: Developing with Docker

#65
I was hoping the article was about using a Docker container *as* your development environment. Talk about easily compartmentalizing and standardizing your projects across machines.

Imagine if you got to a new job and your setup instructions were literally `docker pull mycorp:development.mobile && docker run mycorp:development.mobile`.

- Oh, your machine was lost? Take your new machine and docker pull docker run.

- Someone migrated project A to python 3.8 but project B still requires python 3.6? docker pull docker run.

- You have to work on some backend code? docker pull docker run.

- But the backend code uses an IDE that I don't have installed. Docker Pull! Docker Run!

Every job I've ever started has come with a sheet explaining how to set your machine up to work on the codebase. Install this, upgrade that, change this environment variable, and for the love of god don't install a newer version than this. I mean, I know I've been lucky to get a sheet, but this is usually the first full day of work.

I've never really tried to get this going. I assume that it'd be possible to get an OS instance up in docker that you just VNC into. Load up that image with the tools you need (IDE, git, etc.), wire up some stuff for security (GitHub keys, probably other stuff), and clone the initial commit of your repo so that people can just `git pull` the rest.

Maybe this is a thing. I haven't looked in a few years.

Re: Developing with Docker

#66
post #8

Earlier quoted context omitted.

I hate container and Docker in ANY use-case where there is an alternative that is same, or even "a little bit" more involved. I reserve Docker and Containers for that use case where I really would have headaches if it is no there, and have not still found such a case in all the works I've done.

One thing Docker helps with is reproducibility. If you write your images properly (not many people do) then you can have exact same conditions for every time you run tests. If you keep databases on the host machine, instead of containers, you will have to have some cleanup steps and automate somehow, that they are always run. Otherwise you risk shaky test results or even false positives/negatives. That might be fine,…

> same conditions for every time you run tests

I can understand it is something desirable sometimes... but most of the time that is exactly what I do not want of a test! I want to have everything changing, so I can test under other conditions. Running same test, for the same code, under the same conditions more than once, is redundant

Post reply on HN