this post was submitted on 20 Jun 2023
7 points (88.9% liked)

Programming

3347 readers
1 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 2 years ago
MODERATORS
 

So, I've been living under a rock for the last few years and haven't had the chance to use Docker in development. I'm working my way to get up to speed and have grasped the basics, such as Dockerfile, CLI, etc.

What is unclear to me is how to use Docker while I'm actually writing code. Do I run it inside the container and attach a debugger? Or do I develop in the traditional way (setting up my dev machine like it's 2010) and only push the container to a registry once I'm happy with the changes?

How do you guys use it? Is there a typical way at all?

top 5 comments
sorted by: hot top controversial new old
[–] badcommandorfilename 4 points 1 year ago (1 children)

VScode devcontainers are ideal. You basically debug your code running inside the container.

[–] DLAN 1 points 1 year ago

I am nervous about using them because I already have a docker compose setup and I worry the dev container won’t match what I am expecting. So I just use the standard docker container from my compose file and call that good enough. VScode integration makes it painless enough anyway.

[–] TitanLaGrange 4 points 1 year ago* (last edited 1 year ago)

I don't use Docker for development. I find that it just gets in the way, slows me down, and distracts me. It might be a different experience for software stacks that I don't use. I mostly use C#, Blazor, or React Native while coding in a Windows environment. I'm quite comfortable on the Linux terminal as well, but my current professional work all targets Windows deployments.

I do use Docker for other systems that the thing I am working on needs to connect to. For example, I love MailHog for running a local email server for testing. I usually set up a Docker Compose file for a few external systems that my app needs to use and run them while I'm testing, with my app either running directly on my workstation or in a VMWare machine.

The only exception to this is when I write a Docker Desktop extension, where the container is necessary for testing.

[–] mourkeer 3 points 1 year ago

I use a volume mount to mount my source code then start up the container. For debugger breakpoints, I attach to the container and treat it like any other process.

You can start up containers with docker manually, but I use docker compose so I can have multiple containers and a checked in yaml configuration for how they should run and depend on each other.

[–] CatPoop 2 points 1 year ago

I develop .NET and python on windows in Visual Studio and do the debugging there, then when it all looks stable I’ll commit to git. Then on an arm system, the docker files will pull from git to build the containers, and I’ll do the end-to-end testing there, and rely on the debug logs rather than bothering attaching a debugger.