Development environment in Docker Containers

Thomas Strohmeier
byte\schneiderei
Published in
2 min readApr 9, 2018

--

Over the last two and a half year I was working as a freelance software developer in various environments. One of the most annoying things was the need of having a lot of different software, SDKs, tools, runtimes etc. installed on your machine, especially when they interference with each other and cause troubles in the next project.

During a quite recent work for a customer I came up with the idea to install all the necessary dependencies into a docker container and configure my environment with a docker-compose definition. In this post I will describe my general process of setting up a docker based development environment.
If you have any tips or improvements please write a comment below ;)

1. Image

First I create all the necessary images for my environment. The most important one is the image which contain your development environment.
I give you some examples:

  • php-fpm (Wordpress, Laravel, Magento, ….)
  • java/openjdk (Java EE, Spring Boot, Spark, …)

I prepare my images for the development environment in a way that I only have to mount my project directory into a path and can start my work from there.

Sometimes I also prepare some supporting images like nginx, databases or redis. Fore some services only configuration is necessary but for some I need to add or modify files in the image.

2. Configuration

Next I create a docker-compose definition which contains all the configuration for my containers. The reason my I use docker-compose is quite simple:

  1. Easy to read
  2. You can check it into version control
  3. You can keep all configurations at one place

The important part here is that you mount your project directory as volume into the container and that you expose and map all the required ports.

3. Documentation

It really doesn’t metter if you set up this environment for you or a whole team, documentation is always good. For me a good documentation should contain at least the following point:

  • How to build the environment
  • How to start & stop the environment
  • How to enter the container
  • How to work with this environment (some basic commands)

4. Build and Start

Now you can have fun developing on a clean machine and if you crash your environment during development, just delete and rebuild and start the container and you have a reseted environment. :D

One of the benefits of this method is that new developer, don’t have the need to setup there environment, anymore.

--

--

Entrepreneur | Student @ TU Graz | Software Engineer | DevOps | love learning & teaching | business software | privacy | https://byteschneiderei.com