Walkero

web developer, Drupal follower, Docker ninja, JS explorer, PHP believer, Amiga enthusiast, truth seeker, parent & husband... at least for now...

I like to work and experiment on totally different projects all the time. Every month I intend to put my hands on something new and interesting, discovering exciting technologies and solutions. This means that I usually find myself working on totally different things, from Electron applications to Drupal websites to python scripts or pure C code, and the list goes on and on.

The last thing that I need is to have a development environment a complete mess. But, how can you keep everything organized and clean, and most of all, flexible to change?

I use docker for more than 3 years now, in a way that gives me the possibility to be flexible on change, and support all my needs on any project. And a have a few good reasons why I choose docker.

1. Easy to set up 

docker is really easy to install on any machine. There are versions for Linux, Windows and MacOS available, totally free, ready to download and use. For Linux there is docker CE available at distributions’ repositories. For MacOS and Windows there are Docker Desktop for Mac and Docker Desktop for Windows.

Also, I use docker-compose for the installation and configuration of my containers, using YAML files per project. I surely propose you to install it as well, because it will make your life much more easy. 

2. Works the same way on every OS

No matter what is your preferable operating system, with docker you can have the same experience anywhere. Especially if you work in a team of developers, all the team members will have the same development environment, with no differences. That way you eliminate situations like “But, it works on my machine”.

3. Based on community

You don’t need to reinvent the wheel, nor you need to be a devop to use docker for development. There are thousands of docker images, which you can use at any time, and you can find at docker hub.

You have to take care though what exactly you are using. Check how many are using the image you found. Is it based on official images? Is it certified by docker? How were they build?

4. Extend it

Let’s say that you found a very good and suitable image, but while you work on your project you realize that it is not 100% what you wanted, what can you do? You can go and search for an other image or you can extend it and create your own images, which you can share with your team and maybe with the rest of the community. This way you minimize the possibility to have different development environment inside the team.

5. Lightweight

Based on the way docker works, where you can have multiple containers based on the same image, makes it extremely lightweight. The reserved space in your hard disk will be the absolute minimu because only the changes from the base image are saved. For example, if you use a PHP image in multiple containers, docker doesn’t reserve multiple times the same amount of data in your hard disk.

There are also images based on OS distributions that reserve small space, like the Alpine Linux.

6. Different technology versions

Depending on the structure of your containers, there are ways to have different images with different versions of the same technology. For example, what I like to have is different versions of PHP, i.e. 5.6, 7.1 and 7.2. This helps me to be able to run legacy code, while whenever I want, I can easily change it to a newer version and work on resolving issues.

7. Easy to transfer

If you use plain docker commands or docker-compose, you just need to recreate the development environment on any computer that has docker installed. You don’t need to transfer hundreds of MB, because you can always pull the images from the online repositories. If you happen to use version control system with your code, just pull it as well and you are ready to start working again.

8. Isolated applications and security

A docker container image contains all the necessary software for your application to work, including code, system tools, system libraries and settings. Containers do not use software from the host computer in any way and cannot access the host system files. This makes them pretty secure for you to work on.

9. Easy shareable and strong community

We can find docker containers everywhere, in Data centers, in Cloud, in Serverless systems, in Linux, Windows, MacOS and many others. This means that there is a really big community where you can find help and information.

There are many events happening around the globe, the biggest of all is DockerCon, where you can meet many people that use docker.

Wrapping up

Before I wrap up this post, let me give you a list of useful stuff that might be help you starting with docker.

Most of the well know IDEs there are plugins for docker, which can help you manipulate your local containers. I like to use VSCode, and I recommend an extension named... eehm... Docker.

For containers manipulation I recommend to use Portainer, which can be used as an individual container. With that you can create, start, stop, delete containers or images, you can investigate logs, get info on CPU and memory usage and many other things.

Finally, you can find my own created images at https://hub.docker.com/u/walkero.

#linux #docker #containers #development
- 4 min read