Top

How to use Docker

How to use Docker

Docker containers are hot topic. Our road to use docker took well over six months. On the way we learned a lot and we want to share this with you.

I’ve been testing different methods to manage our development and production environment. I can still remember times when there was no real management. Everything was just installed to your computer and each production server was installed from scratch. Updating production was not that straight forward and those changes at development environment were found after few minutes in production. I did have a look at Puppet and used it for some cases, but it did not last long. We had much better success with Vagrant + Ansible, but only for development. We never had time to install all new server with Ansible. For us continuity is important as many of our projects are long running, oldest has been running since 2005. Even though Puppet and Ansible are great tools they just did not work for our small team.

I had tested Docker few times, but it just seemed so complicated with its docker run commands and custom scripts to make everything work and it didn’t inspire us to upgrade our well working Ansible + Vagrant combo. We were starting a new project at the end of last year and we gave another chance for Docker. This time I learned how Docker composer could help to create whole environment and avoid custom scripting. Hoping it would carry all the way to the deploying system in production. After few long evenings I did manage to get something useful done. Unfortunately soon I understand that like in every system there are some open questions with some boon and bane and deploying was all but clear.

Concept was understood and we did keep coming back and started to use Docker in few places. After some trials and errors I did manage to create nice model with Docker stack that worked for development and was easy to deploy. Now it started to look great!

In real life there are lots of issues to be solved like environmental variables, passwords etc that are required for your system only. There is no silver bullet that Docker will solve, it is up to team to decide how things will be tied together. What I have noticed is that in most cases it helps to have building blocks that should be rather similar. It makes easier to move between projects and you don’t have to start digging that deep every time you need to make a fix for old project. In the end, scripts makes sense and makes life a bit easier and give kind of documentation what you can do and how. In the end I ended up making scripts to generate new Docker stack with all required environmental variables, SSL certificates and passwords.

I wanted that our projects shares a common ways how they are managed. I collected all good practices under one project called DockerStackInstaller. It creates fully working microservice based Docker stack, prepares each service as separate docker image to be pushed to a registry and creates new Git repository to be pushed to GitLab or GitHub. It even gives you some instructions how to prepare your Docker registry and GitLab or GitHub repository. All this has reduced time that it takes to start up a new project and as a bonus each has a same base model with working concepts. Each stack is a fresh copy and not related to DockerStackInstaller at all.

At this time DockerStackInstaller can install you a sample project, Laravel PHP framework, Lumen PHP and empty template for a custom project. Laravel and Lumen are most refined and each build will be ready to be deployed. Deploying your Docker stack in production is a bit of a different task and we’ll get back to that later.

Now as it is still summer it’s good time to learn new skills. Why not to install fresh application with our DockerStackInstaller and see how it works. We would like to get some feedback and ideas what frameworks DockerStackInstaller should support.

Have nice time getting Dockerized!

Tuomas Koponen

tuomas.koponen@oss-solutions.fi

IT-nörtti ja kestävyysurheiluintoilija IT-nerd and ultra distance runner