Docker and Docker Compose

What is Docker ?

Docker is an open source platform for building, deploying, and managing containerized applications. This ecosystem around creating and running containers.

For example the ecosystem contains
1. Docker Client
2. Docker Server
3. Docker Machine
4. Docker Images
5. Docker Hub
6. Docker Compose

Containers simplify delivery of distributed applications, and have become increasingly popular as organizations shift to cloud-native development and hybrid multi-cloud environments.

Simply says , Docker makes it really easy to install and run software without worrying about setup or dependencies.

Docker at Windows/Mac

Simple Example for Docker client — server methodology

What is Container?

  1. Actual problem in normal system

2. Solution in normal system

3. How the Container Works

Commands that we are using

To list running containers =docker ps
To list all containers = docker ps -a
To see images = docker images
To create image = docker create <image-name>
To start container = docker start <container-id>
To start container & show output = docker start -a <container-id>
To run docker=docker create <image-name> + docker start <container-id>
To removing all stopped containers = docker system prune
To retrieving log outputs = docker logs <container id>
To get container id by using image name = docker run -it -d <image name>
To stop container = docker stop <container id>
To kill container = docker kill <container id>
To interact with container to cmd prompt = docker exec -it<container id> sh
To set tag = docker build -t <tagname/some:latest> . (@ current folder)

Creating Own Images

  1. create file — Dockerfile
  2. Config file

3. Build File — On the docker file directory

4. Run Container — docker run <container id>

Running Docker file for Spring-boot Application

  1. Create and build spring boot application
  2. Create Docker file
  3. Create Account in
  4. Create repository at the

Note : Options for connecting these containers
1. Use docker CLI’s Networking Features
2. Use Docker Compose

Docker Compose

Docker Compose is a tool for defining and running multi-container Docker applications at the same time.

With Compose,
1. Use a YAML file to configure your application’s services.
2. Then, with a single command, you create and start all the services from your configuration.

Compose works in all environments:
2. Staging
3. Development
4. Testing as well as CI workflows.

Using Compose is basically a three-step process:
1. Define your app’s environment with a Dockerfile so it can be reproduced anywhere.
2. Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.
3. Run docker compose up and the Docker compose command starts and runs your entire app. You can alternatively run docker-compose up using the docker-compose binary.

Simple Example

On this page you build a simple Python web application running on Docker Compose. The application uses the Flask framework and maintains a hit counter in Redis. While the sample uses Python, the concepts demonstrated here should be understandable even if you’re not familiar with it.


Install docker engine and docker compose

Step 1: Setup — Create directory with any name

Step 2: Create a Project file — Here I used

Step 3: Create text file -requirements.txt

Step 4: Create a Dockerfile

Step 5: Define services in a Compose file

Step 6: Build and run your app with Compose

Step 6: Finally check with browser — http://localhost:5000/

Note : Refresh the browser — you will see the count increment

Step 7: Edit the Compose file to add a bind mount

Step 8: Re-build and run the app with Compose

Step 8: Update the application

Note: Refresh the browser, It updates the changes

Step 8: Stop all services

I think this article was helpful to understand the docker and its features with small practical example. Stay in touch to learn more about latest technology.





Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Automate Installation and Configuration of Apache Tomcat 8.5/9/10 with Ansible

Asynchronous actions, real time updates and AWS AppSync

A Letter from NSI Senior Fellow ________

Reading and Writing to Azure Log Analytics

Conversion of Infix expression to Postfix expression using Stack data structure

Android’s New Dessert: Android Q

Strategy Design Pattern in Java 8

Kotlin — Copy (big) files

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Paul issack minoltan

Paul issack minoltan

More from Medium

Docker networks explained — part 2: docker-compose, microservices, chaos monkey

How Container is better than Virtual Machines ??

How to run docker and docker-compose commands inside your Jenkins Container

How to deploy a Camunda Spring Boot application to an external application server