Hacker News new | past | comments | ask | show | jobs | submit login

This was a good article and looks like an interesting project.

Regardless of whether or not you choose to _deploy_ with Docker, _developing_ in Docker containers using the VS Code Remote extensions really solved all of Python's (and Javascript's) annoying packaging problems for me, with the bonus that you also get to specify any additional (non-Python) dependencies right there in the repo Dockerfile and have the development environment reproducible across machines and between developers. YMMV, of course, but I find this setup an order of magnitude less finicky than the alternatives and can't imagine going back.




Ive never quite managed to get the hang of setting up a dev container. I'ts a bit too tricky for me.

I have resorted to using a throwaway dev container which mimics the local storage of packages. Hopefully someone find the below bash function useful.

The only issue I have using this method is that I cant use VSCode to Debug, which I am hoping to find a nice solution for, but nothing yet.

  function python() {
     docker run \
         -it --rm \
         --name python_$(pwd | sed 's#/home/##g' | sed 's#/#.#g')_$(date +"%H%M%S") \
         -u $(id -u):$(id -g) \
         -v "$(pwd)":"$(pwd)" \
         -w "$(pwd)" \
         -e PROJECT_ROOT="$(pwd)" \
         -e PATH="$(pwd)/vendor/bin/:${PATH}" \
         -e PYTHONUSERBASE="$(pwd)"/vendor \
         -e PYTHONDONTWRITEBYTECODE=1 \
         -e PIP_NO_CACHE_DIR=1 \
         --net=host \
         -h py-docker \
         python:3-slim \
         /bin/bash -c '/bin/bash --rcfile <(echo "PS1=\"[$(python --version)]:: \"") -i'
 }



That's my point. I've always found it hard to set up dev containers. Also each dev container requires its own container, so I may have 10 python docker containers. My implementation only requires 1 image and temporary containers.


I do most of my development in docker. It's tricky to start but once you get the hang of it, it's fantastic. My goal is to one day roll something like RancherOS and provision my entire desktop environment in containers. Then you can just pick up and move it to whatever machine you wish.


I just read this

https://ntietz.com/tech-blog/drawbacks-of-developing-in-cont...

The author highlights some of the problems of using docker in development.


Yeah, I read that too and thought he made some good points.

I probably should have been more careful to qualify my enthusiasm above. I’m definitely not suggesting that everyone that has a Python packaging problem should go out and solve it with Docker. As with all things, there are trade-offs and you should satisfy yourself that Docker is the right tool for your particular problem before diving in.

I just wanted to highlight the fact that - as a VS Code user who has some experience with Docker and writes in a couple different languages and ecosystems - I’ve had a great experience with this modality and find that overall it simplifies my workflow.


I wish the tooling around devcontainer.json was available separately from VS Code. Most of my company are die-hand vim users. We’ve rolled our own “devcontainer” analog but it’s not nearly as seemless.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: