Docker as an Integrated Development Environment (2019)

by albertoCaroMon 4/2/21, 6:44 AMwith 91 comments
by amaranton 4/4/21, 8:47 AM

Personally I'd prefer going with NixOS to achieve the same result. that way you don't even need a docker installation. As a bonus you can actually install the Nix package manager on osx if you're not into Linux (and this way there is no need for virtualization if you're on a Mac)

More info: https://nixos.org/

by sdfhbdfon 4/4/21, 9:40 AM

Hmm i don’t think you can compare IntelliJ which is a fully featured IDE with refractor functionalities, full text search, debugger and so on to a vim setup with plugins in docker container, just because they both edit text. This what the author did at the end of the write up. It’s like comparing jQuery to NodeJS, yeah they both generally are for JavaScript but serve a different purpose.

by tyingqon 4/4/21, 5:59 AM

"Choosing a base image can be quite daunting. I’m always a fan of Alpine Linux for my application containers, so that’s what I chose."

Just be aware that means the musl libc, which is often fine, but not always. Software that expects glibc can crash or have unpredictable behavior. The JVM is a good example, unless you get a JVM that was originally built against musl.

And sometimes also issues with busybox, where it differs from other implementations of the same tools.

by krisgenreon 4/4/21, 7:40 AM

Does anyone use docker for full-fledged development on OSX? I am a Linux user and tried setting up a dev environment for my colleagues on OSX but file system I/O was extremely slow and completely unusable.

by qbasic_foreveron 4/4/21, 7:46 AM

Go the next step and run a local kubernetes cluster with kind or k3s (it will take you 30 seconds to have a k8s cluster going). IMHO the kubectl CLI is a lot more logical than docker's CLI. You can create all your local storage volumes ahead of time, create a pod that attaches to it, and then just kubectl exec into the pod vs. writing a long fiddly docker command line string (or crafting a docker-compose.yml). It's easy to adjust the pod as necessary while it runs too, like adding a service to expose ports without rerunning the container.

But if you do like the idea of docker dev environemnts, check out a tool like batect: https://github.com/batect/batect It's somewhat like if docker-compose had make-like commands you could define. Your whole dev environment and workflow can be defined in a simple yaml config that anyone can use.

by mintycon 4/4/21, 7:29 AM

Update: The original post is from January 2019.

Ashley Broadley's github page at https://github.com/ls12styler sadly doesn't contain a repo with his rust dev work to date (I will ask him as it has some really good stuff in the article.)

----

Very nice. I'm doing similar at the moment. Maybe take a look at

https://www.reddit.com/r/rust/comments/mifrjj/what_extra_dev...

A list of useful cargo built in and third party sub commands.

As you note, common recommended app crates (source) should be gathered separately.

I have several other links and ideas eg supporting different targets such as x86_64-linux-unknown-musl but too long for this post!

by domenkozaron 4/4/21, 9:28 AM

Tutorial on declarative and reproducible developer environments with Nix: https://nix.dev/tutorials/declarative-and-reproducible-devel...

by nyellinon 4/4/21, 6:24 AM

Cool stuff. A few months ago I looked into building a CITRIX alternative based on the idea that you would run application frontends in a local secure docker container while running the backend in the cloud. E.g. you could run VSCode locally while actually compiling in a kubernetes cluster. I eventually ruled out the idea for business reasons, but from a technical perspective it's doable and probably useful. At the time I thought the primary advantage would be reduced cloud costs and lower latency.

by turbinerneiteron 4/4/21, 8:48 AM

I'm currently testing fedora silverblue, which uses toolbox in a roughly similar way. https://github.com/containers/toolbox

One thing that bugs me is that I can't (or don't know how) get my current state into a Textfile, from which I can reproduce.

It's also not fun for embedded development. Guess what, I need to access USB devices, serial, mass storage, hid - super annoying with this setup.

by _ZeD_on 4/4/21, 6:24 AM

if you want an OS as ide... wouldn't be easier to install emacs?

by eptcykaon 4/4/21, 8:10 AM

I find its easier to setup environments via Nix. Its no longer just a bunch of shell scripts.

by zubairqon 4/4/21, 8:22 AM

This is a very good idea to have the whole IDE as one docker container. We do this as well at Yazz:

https://yazz.com/visifile/download.html

by adriancron 4/4/21, 7:46 AM

Nice, similar thing to what I do, a few more things:

1. If you want X11 (haven't figured out audio yet)

"-e DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix:ro"

2. Firefox

> --shm-size=2g

and start with: firefox --no-remote

3. Entering container

Just map a command to enter the container with the name as parameter / optional image type as second.

That way you get a new fresh environment whenever you want

Command would just start if it's not started or exec otherwise. I go extra length to have docker start up a ssh server inside container and I just ssh into it.

by swymon 4/4/21, 6:33 AM

That is a nice write up. We use a very similar set up to containerise our embedded tool chains.

Additionally, we use a wrapper script to symlink the current containerised project to the same location in the host system. This ensures, that outputs in the containerised environment points to valid paths in the host:

E. g.: docker mount: /home/me/dev/proj1234 > /workspace

symlink in host: ln -sfn /home/me/dev/proj1234 /workspace

by de6u99eron 4/4/21, 7:32 AM

I run VSCode and Eclipse Theia in Docker containers and access them via browser. Depending on what I do I start either with a Java, Node, or Python container.

by lifeisstillgoodon 4/4/21, 9:03 AM

I actually do do this - https://github.com/mikadosoftware/workstation

I like the idea of using k8s as suggested upthread. I just have not had much time to push changes / work on it recently. One thing worth thinking about is i have moved to podman - seems a lot slower to start up but is user space which seems sensibke

by alanbernsteinon 4/5/21, 12:33 PM

When I run docker on my laptop, the fans turn on full speed and stay there (recent macbook pro). I kill docker any time I don't expect to use it in the next hour. If I'm not on AC power, it halves my battery life. I wouldn't even consider keeping docker running constantly. Is this not the normal experience?

by zbyon 4/4/21, 6:03 AM

Can you run ansible or terraform inside a docker container?

There are two parts of the dev environment - the programmer preferences and the project libraries and other infrastructure. What I would like is to have a way to compose those two and ideally something that would work the same way inside a docker container as in a full VM.

by chillpenguinon 4/4/21, 7:10 AM

I only get a new laptop once every several years. Doesn't really seem worth it to me personally. I also sort of like starting fresh in a way. Granted I have my dot-files on github to make that part easier. But I don't mind running the install command for things as they come up.

I'm curious if there are other benefits to this approach though besides just saving time when setting up a new machine. The article mentioned "you end up with (in my opinion) a much more flexible working environment." Any ideas what they might mean?

by mark_and_sweepon 4/4/21, 9:34 AM

If you want to do this on Windows, I'd recommend giving https://scoop.sh a try.

by ximmon 4/4/21, 7:28 AM

Especially when doing IT support, having docker on the machines is rather unlikely. This sounds like a good usecase for appimages.

by 3v1n0on 4/4/21, 9:48 AM

Using schroot for years here.

Can do the same but having access to host easier and so to hw devices.

Moving it around my config is easy as having dotfiles around

by yingliu4203on 4/4/21, 2:54 PM

anybody has experience with VS Code inside Container? the feature https://code.visualstudio.com/docs/remote/containers looks nice.

by emptysongglasson 4/4/21, 8:18 AM

Why not just use Vagrant?