Docker has changed the way how we deploy our applications, and there is a chance that even if you are not using Docker directly, it is being used by your cloud provider to deliver your application. For example Google Cloud Functions and Firebase functions are powered by Docker, and even if you are just using simple Node.js app deployed to FIrebase, it is running in Docker container anyway!
But there is not that match of a developers using Docker as a main driver for development environment, because it can be quite complicated to get started with it as a dev environment setup. Most problems coming when you have to decide which volume to use or how to map network ports property to connect containers between multiple projects.
This is of-course not that complicated if you learn how to do that, but at first, it’s not straightforward to do, that’s why most of the developers going to just a raw dev environment setup instead of having containerized setup.
But there is a hybrid mode for that! Which means you can have some projects running and coding directly in your machine, and some of them just running as a containers, and as we know, most of the useful things are just in a gold middle 🙂
Docker containers are just an isolated environments and the most value that I’m getting as a software developer is that I can install some tools and remove them when I don’t need by just removing an actual container instead of worrying about external dependencies and storage cleanup!
I think this is the most important use-case that you will need to have a Docker container for your development environment.
For example when I need to have a Cassandra database which is part of my development process for my Node.js application, I don’t need to worry about installing correct JVM version and Cassandra binaries! I can just pull out Docker image for Cassandra and use it for my local development, then when I’m done, I can just remove an actual Docker image instead of cleaning up my machine from Cassandra’s dependencies!
Of-course it is not ideal for having persistent DB when you need to keep your data, BUT for that cases you can just mount a specific directory on your machine and keep your data even when an actual DB Docker image is removed!
Another Example is that sometimes I need some production environment simulation with Nginx server, BUT I don’t want to have a complicated installing process or custom module complications. For that I can just pull out Nginx container and use my local confirmation to test proxy server locally, and when I’m done, I can just remove an image. Again, whole point is to keep my laptop clean from external software packages and dependencies that I don’t need!
Rest of the development, like an active coding or Node.js or Pythong apps I’m running without Docker container’s, because in 99% cases I need full control of that, like debugging, directory access or even specific environment user access! That’s why I’m calling this processing “Hybrid Dev Environment”.
If you like me, most probably you are going to change your development environment at least once a year, like upgrading your laptop or even just formatting your hard drive to refresh your machine!
For that cases I just keep my dev environment as a single Docker-compose configuration file and hosting my images at treescale.com . This way I can just bring my dev environment up within a few minutes.
This becomes a lot useful when you work in a team and want to share your service with other team mates. They can just setup their environment by just pulling out specific images and have it running in a few minutes.
Development environment setup is something very special to a person who is doing an actual work, so there is nothing that could be as a “best practice”, but if you like me, you will probably avoid having all of that unnecessary dependencies like installing an actual DB or Nginx in your local development environment. Instead, just pull a specific Docker image, then remove it when you are done with it. For me, this is just helps me to keep my laptop clean and my dev environment more predictable for changes.
I mostly work with 3-4 different languages and environment every single day, and having flexible development environment setup is something that I’ve been adapting for a while, and this Hybrid Docker setup helps me to keep my laptop clean and very flexible even when I decided some time to switch from Mac to Linux, I got everything up and running just within an hour or so!
If you have different dev environment setup, just let me know, would be glad to hear some more options!