4. 4
What is Docker?
Docker is a platform for developing, shipping and running
applications using container virtualization from development to
production both on premises and in the cloud.
Docker enables you to separate your applications from your
infrastructure so you can deliver software quickly.
https://www.docker.com/
5. 5
Docker Containers
Docker containers wrap up a piece of
software in a complete file system 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 run
the same, regardless of the environment
it is running in.
8. 8
Docker Containers IN Virtual Machines
Docker in Physical Server Docker in Virtual Machine
9. 9
Why Docker?
AGILITY
Accelerate software development
and deployment and respond
instantly to customer needs.
PORTABILITY
Eliminate the “works on my
machine” once and for all. Gain
independence across on-prem and
cloud environments.
SECURITY
Deliver applications safer across the
entire lifecycle with built in security
capabilities and configurations out
of the box.
COST SAVINGS
Optimize the use of your
infrastructure resources and
streamline operations to save 50%
in total costs.
SIMPLICITY
Docker makes powerful tools for
application creation and
orchestration, accessible to
everyone.
OPENNESS
Built with open source, open
standard technology and a modular
design makes it easy to integrate
into your existing environment.
INDEPENDENCE
Docker creates a separation of
concerns between developers and
IT and between applications and
infrastructure to unlock innovation.
HYBRID CLOUD
Cloud migration, multi-cloud or
hybrid cloud infrastructure require
frictionless portability of
applications.
MICROSERVICES
Docker containers are lightweight
by design and ideal for enabling
microservices application
development.
https://www.docker.com/what-docker
https://www.docker.com/what-container
10. 10
Docker is an Ecosystem
Docker Machine is a tool that lets you
install Docker Engine on virtual hosts, and
manage the hosts with docker-machine
commands. You can use Machine to create
Docker hosts on your local Mac or Windows
box, on your company network, in your data
center, or on cloud providers like Azure,
AWS, or Digital Ocean. Compose is a tool for defining and
running multi-container Docker
applications. With Compose, you use a
YAML file to configure your application’s
services. Then, with a single command,
you create and start all the services from
your configuration.
Current versions of Docker include swarm mode
for natively managing a cluster of Docker
Engines called a swarm. Use the Docker CLI to
create a swarm, deploy application services to
a swarm, and manage swarm behavior.
13. 13
How to Start using Docker?
Docker Installation
Docker website: https://www.docker.com/
Windows : https://docs.docker.com/docker-for-windows/
Mac : https://docs.docker.com/docker-for-mac/
Linux : https://docs.docker.com/engine/
Get Started:
https://docs.docker.com/get-started/
https://docs.docker.com/engine/userguide/
https://aka.ms/microservicesebook
14. 14
Play with Docker (PWD)
• https://labs.play-with-docker.com/
A simple, interactive and fun playground to learn Docker.
PWD is a Docker playground which allows users to run Docker commands in
a matter of seconds.
Under the hood Docker-in-Docker (DinD) is used to give the effect of
multiple VMs/PCs.
17. 17
Docker: Some Vocabulary
Docker Image
The basis of a Docker container. Represents a full application.
Docker Container
The standard unit in which the application service resides and executes.
Registry Service (Docker Hub or Docker Trusted Registry)
Cloud or server based storage and distribution service for your images.
Docker Engine
Creates, ships and runs Docker containers deployable on a physical
or virtual, host locally, in a datacenter or cloud service provider.
Docker Volume
The storage for persisting data generated by and used by Docker containers.
22. 22
Docker Commands
Command Description
docker pull Pull an image or a repository from a registry
docker run Run a command in a new container
docker ps List containers
docker images List images
docker stop Stop one or more running containers
docker rm Remove one or more containers
docker rmi Remove one or more images
docker inspect Return low-level information on Docker objects
docker build Build an image from a Dockerfile
docker logs Fetch the logs of a container
docker exec Run a command in a running container
docker attach Attach local standard input, output, and error streams to a running container
23. 23
docker run hello-world
docker pull microsoft/mssql-server-linux
docker pull splunk/splunk:7.0.0
docker run –it --name mysvr1 ubuntu:16.04 /bin/bash
docker exec –it mysvr1 /bin/bash
docker images
docker ps –a
docker run -d -e "SPLUNK_START_ARGS=--accept-license" -e "SPLUNK_USER=root" -p "8000:8000"
splunk/splunk
docker run -it --rm msyukor/pentestweb nikto –h http://www.website666.com
docker stop 4f85e883cb5d
27. 27
Running Docker Container
docker run -v /path/to/app:/app –P –-name mynginx
bitnami/nginx:latest
docker port mynginx
8443/tcp -> 0.0.0.0:32768
8080/tcp -> 0.0.0.0:32769
Open browser: http://localhost:32769
mynginx
docker run -v /path/to/app:/app –p 28080:8080 –p 28443:8443
–-name mynginx2 bitnami/nginx:latest
Open browser: http://localhost:28080
mynginx2
28. 28
Data Persistence in Docker
Docker container is immutable.
Volume Container is used to store data for a Docker container.
Volumes are the best way to persist data in Docker.
https://docs.docker.com/engine/admin/volumes/volumes/
29. 29
Data Persistence in Docker
Use file system directories (mounting from host) during app development.
docker run –d --name app1_dev -v /home/msyukor/app88:/app bitnami/nginx:latest
easily to edit app in folder /home/msyukor/app88 at development host
TIP #1
Use docker volume for app deployment.
docker run -d --name app1_final -v myvol3:/app bitnami/nginx:latest
TIP #2
31. 31
Build Your Own Docker Image: Dockerfile
Dockerfile docker build command docker image
A Dockerfile is a text document that contains all the commands you would
normally execute manually in order to build a Docker image.
Docker can build images automatically by reading the instructions from a
Dockerfile.
Base images are available at https://hub.docker.com/explore/
33. 33
Dockerfile Format
https://docs.docker.com/engine/reference/builder/
mkdir myapp1
cd myapp1
vi Dockerfile
docker build -t myapp1 .
FROM ubuntu:latest
MAINTAINER author@gmail.com
RUN apt-get update
RUN apt-get install –y curl
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get install –y nodejs
RUN apt-get clean all
RUN mkdir /src
WORKDIR /src
COPY . /src
EXPOSE 8080
CMD [ “npm”, ”start” ]
34. 34
Build Your Own Stack: Docker Compose
Compose is a tool for defining and running multi-container Docker applications.
With Compose, you use a YAML file to configure your application’s services. Then,
with a single command, you create and start all the services from your
configuration ( docker-compose –d up ).
docker-compose.yml docker-compose command docker images
YML
36. 36
Migrating Your Existing Apps into Docker
App Requirement Suitable?
Web based app
Command line app
Standalone native GUI app
IP based app
Needs physical hardware interfacing ports
Humongous storage size
Humongous RAM size
Humongous CPU processing
Needs for speed
App designed for cloud/SaaS
App utilised microservices architecture
TIPS
37. 37
Migrating Your Existing Apps into Docker
Use Docker Hub: https://hub.docker.com/explore/
Choose suitable Docker image for our app.
Choose suitable Docker image tag for our app.
Create directories in development host with suitable structure for our app.
Run Docker container using the chosen Docker image and mounting directories
from the development host.
Debug and rectify the app for bugs and errors (if any).
If all good, deploy the dockerised app into the production.
T I P S
39. 39
Docker DataCenter to power your on-premises CaaS
Docker DataCenter
https://blog.docker.com/2016/02/docker-datacenter-caas/
https://www.docker.com/enterprise-edition
41. 41
Kubernetes
Kubernetes is an open-source system for automating deployment,
scaling, and management of containerized applications.
https://kubernetes.io/
Production-Grade Container
Orchestration.
Automated container
deployment, scaling, and
management.
42. 42
Rancher is a complete container management platform that
makes managing and using containers in production really easy.
http://rancher.com/
Rancher
44. 44
Portainer
Portainer is an open-source lightweight management ui which allows you to
easily manage your docker hosts or swarm clusters.
https://portainer.io/overview.html
45. 45
https://prometheus.io/
Prometheus is an open-source systems monitoring and alerting toolkit
for Docker. Currently, you can only monitor Docker itself. You cannot
currently monitor your application using the Docker target.
https://docs.docker.com/engine/admin/prometheus/
Prometheus
56. 56
Example: ELK Stack
Docker Hub: https://hub.docker.com/r/sebp/elk/
Open browser and browse:
http://localhost:5601
docker pull sebp/elk
docker run -p 5601:5601 -p 9200:9200 -p 5044:5044 -it --name elk sebp/elk
57. 57
Example: Kong API Server
Docker Hub: https://hub.docker.com/_/kong/
docker pull kong
docker pull cassandra:3
docker run -d --name kong-database -p 9042:9042 cassandra:3
docker run --rm --link kong-database:kong-database -e
"KONG_DATABASE=cassandra" -e "KONG_PG_HOST=kong-database" -e
"KONG_CASSANDRA_CONTACT_POINTS=kong-database" kong kong migrations up
docker run -d --name kong --link kong-database:kong-database -e
"KONG_DATABASE=cassandra" -e "KONG_PG_HOST=kong-database" -e
"KONG_CASSANDRA_CONTACT_POINTS=kong-database" -e
"KONG_PROXY_ACCESS_LOG=/dev/stdout" -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" -e
"KONG_PROXY_ERROR_LOG=/dev/stderr" -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" -e
"KONG_ADMIN_LISTEN=0.0.0.0:8001" -e "KONG_ADMIN_LISTEN_SSL=0.0.0.0:8444" -p
8000:8000 -p 8443:8443 -p 8001:8001 -p 8444:8444 kong:latest
58. 58
Example: TensorFlow Deep Learning
Docker Hub: https://hub.docker.com/r/tensorflow/tensorflow/
https://github.com/NVIDIA/nvidia-docker
Open browser and browse:
http://localhost:18888
http://localhost:28888
docker run -it -p 18888:8888 tensorflow/tensorflow
nvidia-docker run -it -p 28888:8888 tensorflow/tensorflow:latest-gpu
59. 59
Example: Python Data Science
Docker Hub: https://hub.docker.com/r/jupyter/datascience-notebook/
Open browser and browse:
http://localhost:8888
docker run -it --rm -p 8888:8888 jupyter/datascience-notebook
60. 60
Example: R Studio
Docker Hub: https://hub.docker.com/r/rocker/rstudio/
Open browser and browse:
http://localhost:8787
docker run –d -p 8787:8787 rocker/rstudio-stable
61. 61
Example: eXo Collaboration Platform
Docker Hub: https://hub.docker.com/r/exoplatform/exo-community/
Open browser and browse:
http://localhost:8080
docker run -v exo_data:/srv/exo -p 8080:8080 exoplatform/exo-community