6 ms·
The Slippery Slope of Docker Dev Environments
- tony 7y agoDisclaimer: I would consider myself one of the developers who tries docker out every couple of years, but just can't seem to get it. > the developer environment just doesn’t square well with whatever system is running your code. In the olden days of yore, this disparity was so great that we often had to tunnel in to an environment that was exactly like our production server For web apps, I've gotten stuff working very easily across linux, freebsd, and mac os. Thanks a lot due to package managers, up to date library packages, and any python/ruby/node packages with c/c++ parts generally being able to find the header/.so files. Lockfiles (package-lock.json, poetry.lock) have gotten better as well, so I feel secure knowing that there won't be hiccups there. Thank you for your comment on docker CLI. I find docker commands more confusing and obtuse to work with than the commands of postgres, python, node, webpack, combined. All of them. Because it's about having to think about copying files, proxying against the file system, layers of containers. By the time stuff is running I feel so far away from the roots, I'm asking myself how much of a favor is this really doing? The other thing is deploying these images is a lot of work compared to just running SSH commands via fabric, pulling code, and restarting services. I also think developers benefit from jumping in and wiring in the daemons themselves on whatever system. I think it's part of what fullstack is. It'll come in useful should stuff go wrong in production. I also found my experimentation with docker inconsistent, even when I cloned projects from git repos with docker compose, I have a high failure rate. To the point I'd be happier if they just gave instructions for me to wire in the daemons and db myself. And when I google, I go down a rabbit hole of configurations and github issues that don't seem to fit (perhaps docker or docker-compose is out of date somehow? Or is it the project itself? Or me?)
- sk5t 7y agoI didn't really buy wholly into containers for a while either, but the tools have gotten better, the process makes it easier to tick the security boxes, and the confidence brought about by immutable deployments and having good visibility into the service state has been really valuable in a growing environment. No more "oh yeah, we poked at ulimit on that server late Friday night, that's why the other ones don't work as well" and so on. No fiddling around with multiple python or java environments. Keep after the details and you can end up not even having anything to ssh into at all--really get out of the game of "server touching" if you will.
- tqkxzugoaupvwqr 7y agoThe past few days I tried putting a personal project with Docker containers together consisting of nginx, certbot, static frontend files (built from source), backend web server. My goal was to be able to call docker-compose up. I’ve done a similar project before without Docker so I know what the end result should look like. Integrating the Docker containers with each other and getting the configurations right is a nightmare. Today I realized I can’t justify the time spent as “learning experience” anymore. What I did was premature optimization that failed terribly and cost me days.
- dpc_pw 7y agoContainers are great, but everything else that Docker does is very meh. Slow, inconvenient, hard to work with. What I'd really want is a system that takes nix files (see Nix & NixOS), and gets that running as a container. Or something like that: Guix or whatever else. Free package-level caching and deduplication, and so on.
- Kaze404 7y agoDoesn't the NixOS CLI do exactly that with virtual machines?
- servilio 7y agoYes, the nixos-container command. That's the imperative approach, you can also do it declaratively. https://nixos.org/nixos/manual/index.html#ch-containers https://nixos.org/nixos/manual/index.html#ch-containers
- zimbatm 7y agohttps://nixery.dev/ https://nixery.dev/ does some of this. `docker pull nixery.dev/shell/git/htop` and you get an image built on the fly with bash, git and htop in it. Each loaded in their individual layers. For a push approach, I am maintaining this project: https://github.com/nix-community/docker-nixpkgs https://github.com/nix-community/docker-nixpkgs Both work well for CLI-like applications. What is missing is to get something similar for services where there is a mix of configuration coming from environment variables and files.
- dpc_pw 7y agoThanks. I will look at this and other comments, but I don't want stuff that involves docker in any way. Only NixOs + containers.
- mikepurvis 7y agoI asked about this a few months ago on here and was pointed to this: https://grahamc.com/blog/nix-and-layered-docker-images https://grahamc.com/blog/nix-and-layered-docker-images It's far from a native solution, and is a bit hacky due to the 256 layer limitation in docker, but it's most of the way to what you want, I think.
- bluedino 7y agoDocker is a savior when you have several different projects with several different versions of a language or slightly different stacks.
- lostapathy 7y agoVery much this. If you only have one project and one set of dependencies, I can see how people don’t see the value in Docker. As soon as you have multiple projects with a mix of dependencies (especially when you’re dealing with incompatible versions or obsolete packages) it really becomes a huge win. Doubly so when you have out of date dependencies that (for whatever bad reason) you can’t update, but also don’t want leaking out into your dev environment.
- geggam 7y agoNow you create an interesting set of issues for the quality and security tests. How do you test code quality and code security as part of your pipeline for all of those different versions on the fly ? eg some run python 2.7 and some run python 3.0
- heretoo 7y agoLet me break your points down (using python 2.7/3.0 as the example): a. Code quality - tackled at code review time, and probably not dependent on python 2.7/3.0 differences; if they are version dependent then again it's a code review process. b. Code security - again, code review Additional: c. Third party dependency vulnerabilities: detection should be automated; github now supports automatic checks that open pull requests for vulnerable artifacts. d. user acceptance tests - seems unlikely that two versions of python are used for the same part of the system. Docker (especially docker-compose) makes it more visible as to what will be deployed. In fact, it may actually be better for security when those security checks of a system can be made before it goes to production, because the whole stack can be built, audited and executed locally.
- geggam 7y ago
- amarshall 7y agoFor development, I’ve found containers to be useful for “arms-length” daemons (that is: databases and similar) as the containers need not change often. It makes it easier to ensure that every project uses the correct version of these daemons, as sometimes the OS package manager may not offer the correct version, or different projects necessitate running different versions simultaneously. As for everyday running of the actual software you’re writing: no way. The tooling for integrating an editor or IDE with the container process is pretty poor (so one often ends up just setting up everything on the host anyway), image rebuilds are frequent and slow, and most language ecosystems already have tools for installing and switching between different versions. They are useful if you want to more closely replicate your CI or production environment for specific debugging, though. Nevertheless, the belief that running a container locally will “never create disparity between your development environment and your production environment” is a farce. There are so many other variables that are often still different. It helps, but it’s far from a silver bullet.
- gravypod 7y agoIn my opinion development environments should be as close to production as humanly possible. Configuration of services, network policies, build systems that are used in CI, etc. The closer you get to sharing tooling and configuration between your development and prod environments the better. Does it make some things more difficult as this author says? At first, yes. As time moves forward you'll end up with many nock on effects that you can't get any other way. 1. Developers can now help you debug that one issue in prod that no one can figure out. 2. Deployment is as easy as adding a line to a config (load dev yaml + patch) 3. Good devs will start automating the boring stuff. Good operators will look at, learn to use, and love these tools. 4. Developers will make sure containers and roll out systems work lightening fast. 5. "We need to run this migration in production. Tested it locally" actually means something now. 6. Demos can be done locally with absolutely no network connection. Demoing to the security minded? Worried about showing off your, often down, production env? No problem! Bring a dev laptop. 7. Developers can test QPS quotas, build dashboards for metric collection, benchmark performance, etc I think it's odd to get hung up on prefixing your commands with "docker-compose exec" or putting "docker-compose up -d --build" under watchman/inotify or investing in setting up minikube + (tilt | skaffold). Sure it's more stuff for your developers to know but it's very powerful to see your change as it effects the entire living system.
- yahyaheee 7y agoAmen, like you mention there are a couple of hurdles to get around but the reproducibility far outweighs that cost. Before docker trying to get virtually anything running on a variety of machines was a total nightmare
- alfiedotwtf 7y agoThis. Every company I’ve ever worked for, to setup a dev environment and get the product passing test suites has been days to weeks. And without the automation and standard operating environment, every release was filled with missing dependencies because developers only tested on their local precious system. A side benefit to moving to containers is not contaminating your own machine with libraries or even breaking it because of versioning or config issues. Docker gets developers and production machines on the same page. ... I would never go back to bare metal development
- muglug 7y agoDeveloping with Docker is pretty great for my colleagues who use Linux laptops. Sadly performance on Macs is woeful (due to architectural differences between the two systems) but even so it's still a very useful tool.
- james_s_tayler 7y agoDocker is great for local dev. I can have a complex docker-compose file with all my dependencies and It Just Works.
- tra3 7y agoI always though of containers as production-level artifacts. In development, I prefer to run most of my environment directly (if possible). Some components can be run as containers if necessary. Containers provide consistency and isolation. I dont think container, as an abstraction, is needed at the development stage. Once development is done, then you pass around a resultant container. For example, I run my Rails projects directly on my Mac (Rails + Native MySQL), my coworker on Linux runs it there natively as well. That means we have to deal with runtime platform issues, true. However when we're ready to "release", we build a container that is then tested, and released to prod.
- hannofcart 7y agoObligatory LXD reference: https://linuxcontainers.org/ https://linuxcontainers.org/
- jasonhansel 7y agoFrom my experience, docker dev environments are great if your host OS is Linux (i.e. if you don't need to run a Linux VM inside of another OS). Otherwise, performance can be very bad.
- misterbrian 7y agoNice article, I feel like I learned a lot of these lessons over the last 1.5 years. Here's a Django/Vue.js project that I have been working on that uses 11 containers for local development (postgres, redis, redis-commander, nginx, node, django, channels, celery, beat, flower and mailhog). I think the weirdest things I have to do for the development environment are all related to hot-reloading, which involves tweaked versions of container start scripts. I run an environment similar to this one daily for work and for some other side projects. https://gitlab.com/verbose-equals-true/django-postgres-vue-gitlab-ecs https://gitlab.com/verbose-equals-true/django-postgres-vue-g... The readme for this project addresses some of the issues that you might have with integration testing. I use GitLab CI and I'm able to take advantage of GitLab runner to simulate my CI environment in containers that run on my local machine. I explored a few different ways of running integration tests in my development environment, one using docker-compose with docker in docker, and another method using services in GitLab CI. I learned a lot from https://gitlab.com/gitlab-org/gitter/webapp https://gitlab.com/gitlab-org/gitter/webapp.
- misterbrian 7y agoI have only used this development environment Ubuntu, I don't know how well it would work on Mac, but I would be curious to try it on Mac and Windows
- skube 7y agodocker and k8s represents everything that is wrong with vc funding of infrastructure companies today it's total shit, insecure, performance sucks, and worst of all you have all these "developer evangelists" on twitter pretending to be developers - but they are not - they are just plain old marketers - just selling you complete utter shit so ready for this trend to be over
- sebastos 7y agoAt my company we just finished setting up a brand new docker dev container that we work out of, and it's awesome. However, it was absolute pain to get it to the point where it's awesome, and the only way it worked at all was because of the fantastic new "Remote: Docker" docker extension that has been released with vscode. Our dev environment is intimately tied to vscode and its ability to interpret a special .devcontainer folder to automagically add in special additional dev layers with project-specific vscode extensions, run all relevant language tools as remote servers inside the container, and provide full intellisense over your project. My questions is, how the hell is anybody getting anything done _without_ all the features I just mentioned? I've found initial, paltry support for particular languages in JetBrains, etc. IDEs, and that's about it. None of the other IDEs have any real solution go getting multi-language intellisense from inside the container. Are people just like... exec'ing into the container and then dicking around in Vim? Or are people mapping all of the source in as a volume, running the IDE outside the container, and just forcing the user to have all the relevant dependencies installed on their host system if they want to see auto-completions, go-to-definition, etc. (thus completely defeating the purpose of containerizing your environment)? In my eyes, the only reason Docker as a dev environment makes any sense at all is because of the uniquely good support vscode offers, but I see it mentioned all over the docker website that it can help you make your development environment repeatable and exactly like your production environment. But... that doesn't actually work, like, at all... Can somebody help me understand what I'm missing?
- dmead 7y agothe second thing. we do this heavily. you map the source directory as a volume and then run the editor outside the container.
- sebastos 7y agoDo you mind if I ask whether you're using some kind of stack where auto-completion, intellisense, etc. is not dependent on any system libraries or dependencies? Or do you just require the developer to install all of those libraries and dependencies on bare metal as well? If it's the latter, isn't that defeating half the purpose of containerizing it? My prediction is that you might be using a stack where it's not a big deal to isolate project-specific dependencies, npm or virtual-env style. And so in that context, it's not a big deal to ask developers to do a pip install -r requirements.txt or whatever, and then the docker container's job is just to emulate the runtime environment. It has just always made sense to me that the win of dockerizing your dev environment would be that you could reproduce it on another machine with a docker pull, so those sort of "half-way" workflows were unsatisfying to me. I'm always curious to hear how other people are doing it though - thanks for responding.
- nhoughto 7y agoWe very successfully run Kubernetes locally, in CI (via kind) and in npe/prod. There are some differences but they have been reduced over time, very strongly recommend this approach to teams for medium+ complexity apps. We basically had Kube in prod, so worked backwards to make everything match that as closely as possible, solving the required problems along the way. docker compose for example is less likely to be used in prod and thus a poor choice.
- mnm1 7y agoWe use docker in production and hand a dev setup. Despite months of work, I don't use the dev setup. One still needs to know a lot about the apps and setting them up to get things going. Rebuilding containers takes a long time and is generally a waste of time. Running workers that loop and check ses, for example, eats up massive amounts of cpu while essentially just looping and doing nothing else. It's hard to know the current configuration and keep track of logs. It's a shit experience compared to some apache vhosts. They are useful for some dependencies and our apps that user end of life tech that would conflict with everything else, but otherwise it's not worth the bother. Even on bare metal Linux it's not worth the hassle. In my osx vm, the docker daemon needs restarting every day. The disk needs to be cleaned regularly. So much overhead for no gain. No thanks. I gave up on this years ago. Great for production though.
- deleted 7y ago[deleted]
- oliwarner 7y agoI use docker-compose because it makes things easier and portable. Instead of opening four terminals and running ./manage.py runserver, npm run dev (twice) and hugo serve, and having project instances of Postgres, Redis and Celery running all the time, I just run docker compose up. I want to move to a new machine? docker-compose up. docker and docker-compose address blooming system complexity very well. I think that's more a reflection of the complexity than docker.
- rudolph9 7y agoPeople conserved with the configuration concerns notes in the article should check out https://github.com/NixOS/nixpkgs https://github.com/NixOS/nixpkgs