Hello programmers, I am Florin Mirosnicencu and today we will talk about how Docker can help you keep your development environment sane and portable.
Before I get into the details and I let myself carried by the enthusiasm I have for this technology, I would like to mention that you can use docker in every environment. You can use it for development, testing and for a production server with scalability in mind.
Docker in a sentence?
Docker allows you to give each project/part of a project it’s own “virtual box”, that meets the dependencies of the project, and allows you to easealy replicate your setup on a new machine, for example.
Docker has portability in mind
The most useful thing about docker is the fact that it helps you separate your projects from your machine. Instead of using the language and packages that your development box has, the projects that are using docker will have their own version that is independent of other projects.
Based on this idea, you can upgrade your software and packages without the fear of breaking one of your projects, as long as Docker is supported.
IT’S PORTABLE. I currently work on some large projects, that have been under development for years, and the process of setting up these large projects on my development machine is no longer than 3 steps. I pull the project, call the install docker script, and then call the docker start script.
This allowed me to switch to a new computer in 1-2 h, I have done twice until now, and I am sure that without docker I would be in a multi-day nightmare where I need to install every version of php from 5.5 to 7.3, just so I can run my projects locally.
Docker is really fast
I thought Docker was just a headless virtual machine, but after working with it and learning more about the details behind, I am really impressed.
Also, you don’t need to run Linux to take advantage of docker. Everyone told me that it’s got problems on Windows and Mac and that using it on Linux is recommended. I fell for this trap the first time, but after using Docker on all the OS’s mentioned before, without any problems, I would actually recommend that you use it on a Mac.
Because it’s about as fast as running it on Linux, I couldn’t notice any difference between Docker running on my Linux kernel and Docker running in a VM.
If all of your development and testing team use Docker for Mac or Windows, then everybody is going to have exactly the same version, and they are going to update at about the same time.
This helps immensely to reduce the number of “Works on my machine” problems!
You can build it yourself
I know docker is considered more in the territory of DevOps, but I am going to try to implement it on all my future projects. Docker and docker-compose use really simple to understand syntax. Also if you stick to official images when you start learning, the documentation and process for getting the images running are really solid.
Are there any problems?
Yes, Docker can cause problems, but most of the time they are caused by other developers in your team (They install a new package or upgrade one) :). If there is one programmer in your team that is interested in Docker (like me), and he spent some learning about it (like me), he can fix 90% of the common issues.
And remember those issues where somebody installs a new package in the project without announcing, these issues can be handled automatically (still trying to implement this).
I am going to end my very opinionated review of Docker here. I really like this technology and I hope that I will get the chance to include it in all my projects in the future.