Hacker News new | ask | show | jobs
by trevor-e 602 days ago
As someone new to Docker, the thing that is never answered (including in this post, the irony of the title...) is what an actual dev workflow looks like.

Let's say I'm working on a web app. I start my container, awesome. Now I make a code change. What do I do? Since the code is copied in the container, do I have to stop, rebuild the image, and start again? Or does it automagically rebuild like most frameworks support? And how about debugging, are there any hoops to jump through connecting a debugger to a container? And what about the filesystem. If I need to inspect the output of something, say a log file in the container, is that easy to do? I've tried this before and got pretty lost trying to access the filesystem.

None of these questions are obvious to Docker beginners like myself. We get the whole "consistent environment" benefits of Docker, now talk about a practical workflow please. :)

edit: thanks for the answers!

3 comments

Generally speaking - you can just mount the local directory in the container (this is particularly easy with docker compose) during development.

https://docs.docker.com/engine/storage/bind-mounts/

Then there's no need to rebuild or restart your container while developing.

For debugging, it depends a bit on the tool - anything that expects to interact through a network port is very straightforward (just expose the port locally, and run the tool as usual). If it needs more than that, it can be more complex.

You can mount volumes in your Docker containers: what I usually do is mount my host source directory over the container's source directory, so that changes are immediately visible inside the container, and then hot reloading in e.g. Flask works exactly like you expect.
If you are using VSCode, you can run VSCode inside a container. Otherwise, most people run the code environment outside a container.

Also, read 12 Factor, logging to a file is wrong. Logs go to standard out.

Thanks for the 12 Factor tip, makes sense.