Everything you need to know about Docker

21
What is Data Driven Product? Docker and Orchestration A.Akkus

Transcript of Everything you need to know about Docker

Page 1: Everything you need to know about Docker

What isData Driven Product?Docker and Orchestration

A.Akkus

Page 2: Everything you need to know about Docker

Agenda

1. What is the Docker?

2. Docker CLI & Docker HTTP API

3. Docker Machine

4. Docker Compose

5. Docker Swarm

6. Docker for Development Env.

7. Demo

Page 3: Everything you need to know about Docker

What is the Docker?

• Docker is the world’s leading software container platform.

• Docker simplifies software delivery by making it easy to build, ship, and run distributed

applications.

• Eliminate the “it works on my machine” problem once and for all.

• Deploy both microservices and traditional apps anywhere without costly rewrites.

• From one to thousands of containers without breaking a sweat.

• Secure by default.

Page 4: Everything you need to know about Docker

What is the Docker?

Page 5: Everything you need to know about Docker
Page 6: Everything you need to know about Docker

Dockerfile

FROM java:8VOLUME /tmpADD target/challenge-0.0.1-SNAPSHOT.jar challenge.jarRUN bash -c 'touch /challenge.jar’EXPOSE 8080ENTRYPOINT ["java","-jar","/challenge.jar"]

Page 7: Everything you need to know about Docker

Best practices for writing Dockerfiles

• Containers should be ephemeral• Use a .dockerignore file• Avoid installing unnecessary packages• Each container should have only one concern• Minimize the number of layers• Sort multi-line arguments• Use the multi-stage build

Page 8: Everything you need to know about Docker

Docker CLI

• To list available commands, either run docker with no parameters or execute docker help.

$ docker

Usage: docker [OPTIONS] COMMAND [ARG...] docker [ --help | -v | --version ]

A self-sufficient runtime for containers.

…….

• Quick demo.

Page 9: Everything you need to know about Docker

Docker HTTP API

• By default, a unix domain socket (or IPC socket) is created at /var/run/docker.sock

• If you need to access the Docker daemon remotely, you need to enable the tcp Socket.

• You can do following items;

* Run a container

* Update a container

* List and manage containers

* Print the logs of a specific container

* Pull images

* List a network

…..

….

Page 10: Everything you need to know about Docker

Docker Machine

• Docker Machine allows you to create Docker hosts on your

computer, on cloud providers, and inside your own data center.

• It creates servers, installs Docker on them, and then configures

the Docker client to talk to them.

• Common commands for Docker Machine;

* create, ls, ssh, scp, inspect, env, start/stop/kill, rm, ip

Page 11: Everything you need to know about Docker

Docker Compose

• Docker Compose is a tool that allows you to define and run

applications with one or more Docker containers.

• Typically, an application would consist of multiple containers such as

one for the web server, another for the application server, and

another one for the database.

• With Compose, a multi-container application can be easily defined

in a single file.

• All the containers required for the application can be then started

and managed with a single command.

For example; docker-compose up or docker-compose up -d

Page 12: Everything you need to know about Docker

Docker Compose

• The Docker Compose file is typically called docker-compose.yml.

• If you decide to use a different filename, it can be specified using the - f option to docker-compose script.

Page 13: Everything you need to know about Docker

iyzicontainer

Page 14: Everything you need to know about Docker

iyzicontainer

Page 15: Everything you need to know about Docker

Docker Swarm

• The cluster management and orchestration features embedded in the Docker Engine are built using SwarmKit.

• You enable swarm mode for an engine by either initializing a swarm or joining an existing swarm.

• Declarative service model.

• Scaling.

• Desired state reconciliation.

• Multi-host networking.

• Service discovery.

• Load balancing.

• Secure by default.

• Rolling updates.

• Configurable Updates.

Page 16: Everything you need to know about Docker

Docker Swarm

Page 17: Everything you need to know about Docker

Docker Swarm - Raft• When the Docker Engine runs in swarm mode, manager nodes implement the Raft

Consensus Algorithm to manage the global cluster state.

• Raft tolerates up to (N-1)/2 failures and requires a majority or quorum of (N/2)+1 members to agree on values proposed to the cluster.

• The implementation of the consensus algorithm in swarm mode means it features the properties inherent to distributed systems;• agreement on values in a fault tolerant system. • mutual exclusion through the leader election process• cluster membership management• globally consistent object sequencing and CAS (compare-and-swap) primitives

Page 18: Everything you need to know about Docker

Docker for Development Environment• Docker containers wrap up a piece of software in a complete filesystem that

contains everything it needs to run: code, runtime, system tools, system libraries —anything you can install on a server. This guarantees that it will always execute the same, regardless of the environment it is running in.

• docker-compose up –d ./run-test.shdocker-compose down

Page 19: Everything you need to know about Docker

Demo• A sample app that uses a Java Spring Boot backend connected to a database to

display a fictitious art shop with a React front-end.

• We’ve 3 swarm nodes(one manager and two worker)

https://github.com/AlicanAkkus/atsea-sample-shop-app

Page 20: Everything you need to know about Docker

Links• Docker;

• https://docs.docker.com/get-started/• https://alicanakkus.github.io/blog/docker/docker-introduction• https://alicanakkus.github.io/blog/docker/docker-images• https://alicanakkus.github.io/blog/docker/docker-containers• https://alicanakkus.github.io/blog/docker/springboot-for-docker• https://alicanakkus.github.io/blog/docker/docker-network• https://alicanakkus.github.io/blog/docker/docker-volume• https://alicanakkus.github.io/blog/docker/docker-compose-en

• Docker hub;• https://hub.docker.com

• Raft;• http://thesecretlivesofdata.com/raft/

Page 21: Everything you need to know about Docker

Thanks