You are viewing our old blog site. For latest posts, please visit us at the new space. Follow our publication there to stay updated with tech articles, tutorials, events & more.

Docker @

0.00 avg. rating (0% score) - 0 votes

Problem statement

Let us go though the problems that we were facing in our development environment.

  1. Deploying multiple applications on a single machine.           

Different applications have different dependencies and package requirements. Deploying multiple applications on one server causes dependency conflicts. For eg. if different applications are supported by different PHP versions. To achieve this one has to install multiple PHP versions on single machine. 

  2. Resource allocation

We cannot control resource utilization (CPU and memory) by different applications easily. This option is provided using LXC, namespaces and control groups.

  3. Different behaviour on different environments

Code bases of an application can behave differently on different environments. This is because installed applications on different environments are not consistent. 

Solutions provided by Docker

1. Deploying multiple applications on a single machine.  

Docker allow us to create images and run multiple containers. All containers run in own namespace and avoids conflicts between diff configurations in other containers. So we can run multiple versions of any tool without conflicting with others. We create different docker images with specific PHP version and applications can extend from or run on these different PHP based docker images.

2. Resource allocation

Using Docker we can use namespaces and control groups easily using command line arguments or confg. Docker-compose provide much better way to run containers and define restrictions in iml config file.

3Different behaviour on different environments

Docker run containers in diff namespaces and can run multiple version tools on same machine. We can build, test and deploy same docker image on different environments.

Intended use of Docker at naukri

At Naukri we aim to build application architecture which behave  consistently across different environments.

We have configured our CI Server to build application docker images triggered by a push to SCM. 

As soon as code is pushed to SCM, CI Server will run UT (unit tests) on application base image. If UTs are passed, CI Server creates an application immutable image. These images are deployed on the test environment after which FTs (Functional tests) and ITs (Integration tests) are run on these deployments. If FTs and ITs are successful, these docker images and related code bases are ready to be deployed on staging and live. Currently we are not using docker for staging and live environments. But all previous steps are done using docker.

For development, we are using docker-compose. Each application has its own docker-compose configuration and can be deployed using a single command.

Docker helps in CI/CD because we can run containers on any nodes easily and porting is easy and OS independent.

How we have used docker? 

Now, that we are aware of the problems that are faced in our development environment. And we know the intention of using Docker at Let us go through the development that we did for using docker in our environment.

Customised base images:

Instead of using public docker images for PHP, MySql, Java and other tools we have built our own images using Centos:7 and ubuntu:14.04 as base images. 

We have patched base images for PID1, cron, syslog problems that can crop up by running ubuntu or any linux distribution inside a docker container. For more details on problems, please check On dev or test environments, we used supervisord as a process monitoring tool in docker containers, that can re-run tools and commands if they crash.

Dev environment

For development we have used docker-compose for application orchestration so that application can be setup in one command. 

We define all dependent services in docker-compose.yml file and use ant to run application containers using docker-compose. Ant helps us to automate all steps to setup application like composer install, copy env specific config files and run db migrations.  

Immutable images:

When our code base is tested (via UTs), a tag is created from tested commit hash and we create immutable image using this tag. Images are build using CI Server which uses application image template and creates immutable image with the same tag.

Auto deployment:

CI Server handles the build and deployment pipeline of UT, tag creation, immutable image creation, deployment on dev servers running kubernetes and execution of FTs. We are using kubernetes for dev and test servers and deployments are easily done on kubernetes through CI Server  How we have setup kubernetes for different environments and different applications will be discussed in a different post.

Posted in Linux