9 reasons why you should use Docker as a development environment
Tags: docker, vscode
Published: 2020-10-09 20:47:50

I have been developing React apps in [Docker](https://www.docker.com/) 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.


![https://images.unsplash.com/photo-1593824854968-7833add41c16?ixlib=rb-1.2.1&auto=format&fit=crop&w=1050&q=80](https://images.unsplash.com/photo-1593824854968-7833add41c16?ixlib=rb-1.2.1&auto=format&fit=crop&w=1050&q=80)_Photo by [Noel Broda](https://unsplash.com/@brodanoel) on [Unsplash](https://unsplash.com/)_

### 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.


![https://images.unsplash.com/photo-1528660493888-ab6f4761e036?ixlib=rb-1.2.1&auto=format&fit=crop&w=334&q=80](https://images.unsplash.com/photo-1528660493888-ab6f4761e036?ixlib=rb-1.2.1&auto=format&fit=crop&w=334&q=80)_Photo by [Steve Halama](https://unsplash.com/@steve3p_0) on [Unsplash](https://unsplash.com/)_

### 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](https://kubernetes.io/).

### CI/CD

Some CI/CD providers (like [CircleCI](https://circleci.com/)) 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.


![https://images.unsplash.com/photo-1556075798-4825dfaaf498?ixlib=rb-1.2.1&auto=format&fit=crop&w=1055&q=80](https://images.unsplash.com/photo-1556075798-4825dfaaf498?ixlib=rb-1.2.1&auto=format&fit=crop&w=1055&q=80)_Photo by [Yancy Min](https://unsplash.com/@yancymin) on [Unsplash](https://unsplash.com/)_

### 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](https://www.gitkraken.com/) for example).

Check out the [VSCode docs](https://code.visualstudio.com/docs/remote/containers) 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 you decide to go with Docker for your next project, check out these tips to improve your productivity:

{% medium https://danielgaldev.medium.com/speed-up-your-docker-workflow-with-bash-functions-45f522bd87a4 %}

## Other useful resources

Check out these writings on Docker and containers in general:

{% medium https://medium.com/free-code-camp/a-beginner-friendly-introduction-to-containers-vms-and-docker-79a9e3e119b %}

{% medium https://towardsdatascience.com/learn-enough-docker-to-be-useful-b7ba70caeb4b %}

This article is also available on Medium.
{% medium https://medium.com/@danielgaldev/9-reasons-why-you-should-use-docker-as-a-development-environment-96e2ce154194 %}