9 reasons why you should use Docker as a development environment

Dániel Gál
5 min readOct 9, 2020

--

I have been developing React apps in Docker for a few years now, and so far nothing was able to stop me from containerizing every project I get started with.

This article is perfect for you if you read about containers or already started playing around with them, but you are not yet sold on the idea of using them as a development environment. If you have no idea what a container is, check out the links at the bottom.

This is more of a “meta” writing about container based development, not a guide on getting started with it. If you are looking for some tutorials, hit up the search bar above.

Shipping containers, axonometric perspective
Photo by Noel Broda on Unsplash

No clutter on your PC

Know the feeling of working on multiple projects and having 4 versions of Node, 2 versions of Python and 3 separate database management software installed on your machine? Do you have the habit of starting a new project every few months to try out a new trending technology, but during the struggle of setting it up and getting a “Hello World” app to work you lose your motivation?

With Docker, all the software required to run your app is inside the container. This gets us to the next reason:

No other software needed

At least not on the host computer (your machine). Given a fresh install of Windows, macOS or Linux, once you install Docker, you can just clone the project repository and fire up your app. If you set the environment up right, it should work out of the box.

Isolated environment

What happens in the container, stays in the container. You can install all the dependencies you want, it will not affect your host machine. The opposite applies too, the other software installed on your computer will not interfere with your app in the container.

Works anywhere

If a computer has Docker installed, you can develop your app on it without effort. If you want your friend or colleague involved in creating your app, they don’t have to spend hours installing software and dependencies. The just need to give one universal command and they are ready to go. If you don’t like taking your computer to and from the office you work at, you can have the same environment on both machines with Docker. You can even set it up on a server and attach to it remotely.

Photo by Steve Halama on Unsplash

Easy cleanup

Once you are done with a project, just delete the image and any containers you created, and you’re good. It doesn’t take up space on your machine anymore. If you change your mind, you can build it again with one single command. Without Docker, you would have to remember all the software you installed just to get a project running, and get rid of them individually to free your computer from the stuff you don’t use anymore.

Easy on disk space

Not everybody has terabytes of SSD storage these days. Maybe you only own a 256 GB drive, like me. Working on multiple projects, having 5 different IDEs and many libraries installed takes its toll on your storage space. With Docker, if you put a project on hold, you can just delete its images and containers from your computer. You can easily build it again if you want to continue and you will get the same environment.

It is also possible to persist files across builds with the help of volumes, so you don’t have to delete and recreate some parts of your app every time, for example a database.

Gateway to production

The skills learned trying to configure a Docker environment for the development process might come in handy when you’re shipping your app. Chances are you will deploy it on some kind of cloud infrastructure that supports containers like Kubernetes.

CI/CD

Some CI/CD providers (like CircleCI) offer the possibility of using containers in your builds. Since your environment is already a container, little to no configuration is needed to make your app test and deploy itself automatically.

Photo by Yancy Min on Unsplash

VSCode Remote — Containers

This VSCode extension is so great, it deserves its own section. To be honest, it is the main reason why I wanted to share this knowledge with you.

Before this extension existed, if we wanted to edit the code in the container without restarting it every time we made a change, we had to mount the project folder as a volume. If you changed the file on the host computer, it changed in the container as well. This had (still has) some problems.

Technology reliant on filesystem events like live reloading were a pain to work with. They were not as reliable because the filesystem events did not happen in the container (a shortcoming of mounted volumes), and on many occasions polling was required, draining your computer’s processing power just to watch file changes.

With VSCode Remote — Containers, these problems don’t exist. You can attach VSCode to the container itself, open the project folder inside it and get to work. The file changes now happen inside the container, no need for polling or mounting the code as a volume.

Mounting the code is still a good idea though, if you want to use version control software on the host computer (a Git client like GitKraken for example).

Check out the VSCode docs on developing inside a container:

Conclusion

The community behind Docker based development environments is strong. The most popular languages, runtimes and frameworks like Node, Python and Ruby have a plethora of guides to help you Dockerize your development experience. If the reasons listed in this article made you curious about this way of creating software, make sure to try it out!

If I convinced you to switch to Docker for development, check out my guide on setting up a quick Node.js development environment:

Once you got the grip of this new development style, check out these tips to improve your productivity:

Other useful resources

Check out these writings on Docker and containers in general:

--

--

Dániel Gál
Dániel Gál

Written by Dániel Gál

React Developer, frontend enthusiast, student

No responses yet