Wikipedia defines Docker as

an open-source project that automates the deployment of software applications inside containers by providing an additional layer of abstraction and automation of OS-level virtualization on Linux.

What is a Docker Compose file?

Dockerfile is used to build a docker image and docker run command to run the application. While building a solution generally there will be many number of applications. What if there are hundred of them? Oh God... Please help the deployer of these applications. Docker-compose comes to our rescue. With a single command the tedious task of running each application can be done effortlessly. Docker-compose helps to start all the applications from the provided configuration. In this post we will learn from how to install docker-compose and finally use it.

Install docker-compose

The steps from 3 show how to install docker-compose. For those who already have installed the docker-compose but want to upgrade can follow from step 1.

Step 1: Check for the version and remove

	docker-compose --version

docker_version

	sudo apt-get remove docker-compose

docker_core

Step 2: Download and install

	sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

docker_core

Give all permissions

	sudo chmod +x /usr/local/bin/docker-compose
	sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
	docker-compose --version

dockercompose_permission

Creating the first docker-compose file

In my previous post I have mentioned how to create a hello world docker image.I will be using the same docker image in this example. Check for the hello world image using docker command. ``` docker images ``` images

Run docker-compose

Use this command to run the docker image. A default network is created in case we don't provide a network.

	docker-compose up

dockercompose_up

Run the docker-compose in a background mode

This command help to run the containers in a silent mode.

	docker-compose up -d

Stop the running containers

	docker-compose down

An Example

The following example shows a docker-compose file which has various services along with zookeeper and kafka.

If you have any question or feedback, please do reach out to me by commenting below.