Dev containers to the rescue
Tags: docker, dev, container, cloud
Published: 2023-01-02 10:23:33

Ahoy devs!

What if you could write a few lines of code while waiting at the dentist?

What if setting up the project for the first time was a non-event instead of a minor trauma? 

What if the frustration of a project failing to build on a single developer's machine was eliminated?

Dev containers to the rescue!

<h3>What if you could bundle your dev environment with your code?</h3>
Using human-readable configuration files that are versioned alongside the project's <a href="https://codingforspeed.com/how-do-you-protect-the-source-code/" title="How do you protect the source code?">source code</a>, we determine which OS version, system packages and libraries, utilities, filesystem mappings, open ports, and supporting services will be included in a dev container.

So that a portable, reproducible <a href="https://codingforspeed.com/benefits-of-infrastructure-as-code-for-developers/" title="Benefits of Infrastructure as Code for Developers">development environment</a> follows you from machine to machine and into the cloud.

<h4>Why are containers better for development than virtualization solutions?</h4>
It's because containers aren't really virtualization. Containers are like a computer inside a computer. A container works by generating an isolated set of namespaces rather than attempting to emulate a <a href="https://helloacm.com/teaching-kids-programming-introduction-to-knn-machine-learning-algorithm/" target="_blank" rel="noopener">machine</a>. Included are the filesystem, the network, the process table, and everything else that makes up a functional OS.

You can make it simpler for others to contribute to your open-source projects. You can verify that every CI test can also be done locally. You may share your development configurations and scripts with your fellow devs with a GitHub push. You could even spin it on a designer's workstation so they can test visual changes locally across in-house codebases without knowing the backend tech stacks.

<h4>Problems should be reproducible</h4>
Have you ever had a developer on your team start having problems that no one notices? 

After much debugging, it was discovered that they had gotten a system upgrade incompatible with one of the libraries on which the project is based. Nobody could help them because... it worked on their machine!

Using dev containers regularly can significantly reduce the "works on my computer" syndrome. 

<h4>Onboarding new devs</h4>
A puzzling, time-consuming, and frequently out-of-date onboarding process is the standard on most teams. 

You're a champion if you can get a portion of the project's test suite running during your first week of onboarding! 

With dev containers, you can get new hires up and running in an hour instead of days.

<h4>Shift between projects</h4>
Because a dev container is dedicated to a single project, the appropriate version of the environment can be installed with it. If this necessitates compiling the runtime from the source, this can be incorporated into the development container.

<h4>Distribute vital utilities</h4>
Once a project is configured on a machine, we forget the checklists and scripts. However, dev containers are recreated regularly whenever they are modified. 

A dev <a href="https://codingforspeed.com/shift-from-local-to-remote-working-dev/" title="Shift from Local to Remote Working">container</a> is an executable documentation of what libraries, services, system configurations, open ports, nice-to-have utilities, and so on are used in your project's day-to-day development.

The dev container.json file contains all necessary metadata and settings for configuring a development container for a specific tool and runtime stack. It can be used to establish a dev environment containing one or more containers with tools and services that satisfy the dev spec.

<h4>Everyone has access to all of the tests at all times.</h4>
We can raise our expectations to everyone can run all the tests, all the time, with a dev container that everyone shares and that is also utilized in CI. They may still run faster in parallel on CI, but passing the integration tests becomes everyone's responsibility.

Because dev containers can bundle up not just a little machine for developing the app itself but also the constellation of supporting services required to operate the app, they can handle the entire testing cycle.

<h4>IDE in the Cloud</h4>
<a href="https://helloacm.com/tutorial-how-to-set-up-a-api-load-balancer-by-using-cloudflare-worker/" target="_blank" rel="noopener">Cloud-based</a> programming with solutions such as Codeanywhere, Gitpod, or GitHub Codespaces is a thing now and will only get more popular.

The dev container in Codeanywhere cloud IDE can have a base level of project-specific settings and plugins, but you can also add your own settings, plugins, colour schemes, keybindings, and so on top of that.

Remote pair programming is possible in cloud-based development environments.

What if open-source projects included dev <a href="https://helloacm.com/bash-function-to-install-docker/" rel="noopener" target="_blank">containers</a> that made casual contributors effective immediately? Casual contributors may find it much more inviting!

Similarly, your team is not required to settle on a single editor. Dev container-aware configurations for various IDEs can be included in a project.

<h4>Certain technologies, once matured, irrevocably alter the developing state of the art.</h4>
This is the developer experience of the future. You can start enjoying the future today by utilizing containers for the development and flexibility of cloud IDEs.

Reposted to [Blog](https://codingforspeed.com/dev-containers-to-the-rescue/)