Docker compose and swarm

Post on 07-Jan-2017

103 views 3 download

Transcript of Docker compose and swarm

Docker Compose and Docker Swarm By Tanmay Mehra

What is Docker ? Docker is an open platform for developing, shipping, and running applications.

Docker provides a way to run almost any application securely isolated in a container.

The isolation and security allow you to run many containers simultaneously on your host.

The lightweight nature of containers, which run without the extra load of a hypervisor, means you can get more out of your hardware.

Docker Components

Docker: the open source container virtualization platform

Docker Hub: SaaS platform for sharing and managing Docker images

Docker Daemon runs on a host machine and does the heavy lifting of building, running, and distributing Docker containers.

Docker client is a Docker binary that accepts commands from the user and communicates back and forth with daemon.

How does it work ?

Docker Demo

Create docker-machine

Pull an image

Create a Container

Start a container

Stop and Remove a container

Docker Compose

Compose is a tool for defining and running complex applications with Docker.

With Compose, you define a multi-container application in a single file, then spin your application up in a single command which does everything that needs to be done to get it running.

Compose is great for development, testing, and staging environments, as well as CI workflows.

How to use Docker Compose ?

Define your app’s environment with a Dockerfile so it can be reproduced anywhere.

Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.

Lastly, run docker-compose up and Compose will start and run your entire app.

Docker Compose

Docker Compose Demo

Install docker compose

Create a compose file docker-compose.yml

docker-compose up

check containers created

check server up

Docker Swarm

Docker Swarm provides native clustering to Docker.

It turns a pool of Docker hosts into a single, virtual Docker host.

Docker Swarm solves one of the fundamental limitations of Docker where the containers could only run on a single Docker host.

Docker Swarm Components

like consul, zookeeper and etcd.

Swarm Scheduling Strategies

The Docker Swarm scheduler features multiple strategies for ranking nodes. The strategy you choose determines how Swarm computes ranking.

spread: Swarm optimizes for the node with the least number of running containers

binpack: The binpack strategy causes Swarm to optimize for the node which is most packed.

random: The random strategy, like it sounds, chooses nodes at random regardless of their available CPU or RAM.

Docker SwarmDemo

Create Swarm manager

Create Swarm nodes

Join swarm nodes with Swarm manager

Create containers using swarm manager

Run the application

Thank You !!