Live data from Hacker News

VSCode, Dev Containers and Docker

blog.feabhas.com

21–30 of 234 posts

Re: VSCode, Dev Containers and Docker

#21

Earlier quoted context omitted.

If you have projects with different versions (python2/3, Java5/8, node8/11 etc) you don't need to bother with version managers and package managers anymore. Just launch the respective container and you are good to go.

for python, why cant you use use virtualenv with pyenv?

because setting and configuring virtualenv is also chore and loads of things that can go wrong. Its different in windows to mac to linux.

With docker its a single command run after installing docker.

Re: VSCode, Dev Containers and Docker

#22
Slightly off-topic, it really irks me when people take about reproducible builds/environments while using docker, while having something along the lines of apt-get update/pip install in their dockerfile.

Like that completely destroys the reproducibility of your container!

Re: VSCode, Dev Containers and Docker

#23

I understand this can be done. And this post explains how it's done. I still don't get why it should be done? What's the advantage of running your dev environment in a container?

What exactly is diffucult to understand about the value proposition? Seems pretty obvious to me...

If you mean why use dev environments in containers:

1) reproducibility,

2) re-use of container creation scripts for different environments,

3) isolation from your actual OS,

4) ability to run the same OS/libs/etc as the final deployment,

5) tons of base images with different environments already configured - from LAMP to data science,

6) easy sharing with others, team

7) ability to work with 1-2-5 or 100 different environments, with different OSes, versions, libs, python versions, whatever.

As for why have your IDE/editor work from inside a container (as described in the article).

Well, because you get all the benefits of containers (as above) PLUS get to use the editor as if you were programming directly on the target machine (including having visibility of installed libraries for autocomplete, running code directly there, and so on).

It's the same thing people have been doing with running Emacs in "server" mode inside another host, and programming with Emacs client on their machines as if they were locally at the machine.

Re: VSCode, Dev Containers and Docker

#24
post #12
post #7

I've been doing some playing around with dev containers for a while now and am loving the experience so far. The one thing I am not super clear on however is doing end to end browser based testing in Web Apps. I didn't find a lot of good documentation on this currently. I can't tell if the "correct" solution is to also load something like headless chrome into the Dockerfile and install it manually or go down the path…

A headless chrome works for testing. You can even open GUI apps (at least with X11 on Linux) from the container itself, and it will use the host's X session (chrome --no-sandbox). I've been using a containerized Rails app with VSCode for a while now and absolutely love it.

You wouldn't happen to have an example Dockerfile you could share at all would you? The examples I have come across online so far did't look super straightforward.

Re: VSCode, Dev Containers and Docker

#25

I understand this can be done. And this post explains how it's done. I still don't get why it should be done? What's the advantage of running your dev environment in a container?

Since some of the proported features of containers is portability and consistentency/reproducibility between environments, the idea here is that you want to make sure your develop environment is as close to the deployment environment as possible. In addition, if you want to do prototype development, quickly try and test new ideas, and iterate on that, it's nice to go through that without rebuilding and deploying the container to a test/production environment. Do all of that right where you do your development.

Re: VSCode, Dev Containers and Docker

#26

Earlier quoted context omitted.

If you have projects with different versions (python2/3, Java5/8, node8/11 etc) you don't need to bother with version managers and package managers anymore. Just launch the respective container and you are good to go.

for python, why cant you use use virtualenv with pyenv?

You could, but then maybe you have some editor-specific settings you'd also want to tie to particular project.

And if you're working with multiple projects in multiple languages, why bother learning each language's equivalent of virtualenv (assuming it has any), when there's an universal method available?

Re: VSCode, Dev Containers and Docker

#27

Earlier quoted context omitted.

If you have projects with different versions (python2/3, Java5/8, node8/11 etc) you don't need to bother with version managers and package managers anymore. Just launch the respective container and you are good to go.

for python, why cant you use use virtualenv with pyenv?

Because it is a Python specific thing. Docker works with all programming languages and that's it.

If you are full stack or work with multiple programming languages there is no need to learn the "equivalent" of virtualenv everywhere else.

Also with docker there is no setup/installation involved. You just pull the image and that is it.

Also virtualenv requires that you already have pip/python installed. Docker requires nothing (apart from itself). So you can instantly launch Java/Node/Erlang/Haskell whatever without any SDK/libs installed.

Re: VSCode, Dev Containers and Docker

#28

Slightly off-topic, it really irks me when people take about reproducible builds/environments while using docker, while having something along the lines of apt-get update/pip install in their dockerfile. Like that completely destroys the reproducibility of your container!

And by that you mean that the version of those deps aren't pinned?

Re: VSCode, Dev Containers and Docker

#29

Earlier quoted context omitted.

If you have projects with different versions (python2/3, Java5/8, node8/11 etc) you don't need to bother with version managers and package managers anymore. Just launch the respective container and you are good to go.

for python, why cant you use use virtualenv with pyenv?

I wrote this article a while back that compares setting up a Python development environment for web development with and without Docker: https://nickjanetakis.com/blog/setting-up-a-python-developme...

The TL;DR is there's a lot of things to set up yourself without Docker in order to run a typical web application and it's different depending on what OS / version you use. Some of these things are unrelated to Python too, such as running PostgreSQL, Redis, etc. but these are very important to your overall application.

Docker unifies that entire set up and the barrier of entry is installing Docker once and then learning a bit about it.

Re: VSCode, Dev Containers and Docker

#30
post #8

Doing any sort of development with Docker on OSX can be painfully slow if you have a lot of files that change frequently. There are a few projects to improve it but they quite aren't there yet. It's my least favourite aspect of modern web work.

Have you tried docker on Windows? It's even worse.

On OSX I only had problems with GUI running in docker. I was used to sharing X between linux host and docker container also running linux.

For some projects, the only working solution I found was to run a VNC server in docker. Specific example: in a docker container, run a GUI built with Kivy and view the window on the OSX host. If anyone manages to do this without VNC, I'd like to know how!

Post reply on HN