SlideShare uma empresa Scribd logo
1 de 71
Docker for Developers
ANDRZEJ SYDOR
Agenda
 Docker introduction
 Containers: run, start, stop, rm, ps
 Images: pull, push, import, export, save, load
 Networking
 Volumes
 UI tools
 Dockerfile
 Docker Compose
 Best practices
Docker
 Docker is the leading software container platform
 Founded in 2013 as Linux developer tool
 Fundamentally solves the „works on my machine” problem
 Container industry inventor, leader and innovative
 Transform app and infrastructure security, portability, agility and efficiency
One Application on One
Physical Server
 Limitations
 Slow development times
 Huge costs
 Wasted resources
 Difficult to scale
 Difficult to migrate
 Vendor lock in
Hypervisior – Based
Virtualization
 Benefit:
 Better resource pooling
 One physical machine divided into multiple virtual machines
 Easier to scale
 VMs in the cloud
 Rapid elasticity
 Pay as you go model
 Limitations:
 Each VM stills requires:
 CPU limitations
 Storage
 RAM
 An entire guest operating system
 Full guest OS means wasted resources
 Application portability not guaranteed
Docker
 Standarized packaging for software and
dependencies
 Isolate apps from each other
 Share the same OS kernel
 Works with all major Linux and Windows
Server
Key Benefits of Docker Containers
 Speed
 No OS to boot – applications online in seconds
 Portability
 Less dependencies between proces layers = ability to move between infrastructure
 Efficiency
 Less OS overhead
 Improved resource efficiency
WORA / PODA / CaaS
 WORA = Write Once Run Anywhere {J,W,E}AR
 PODA = Package Once Deploy Anywhere
 CaaS = Container as a Service
Docker
 Image
 The basis of a Docker container
 Container
 The image when it is ‚running’
 Registry
 Stores, distributes and manages Docker images
 Dockerfile
 Commands to assemble an image
 Docker Compose
 Define and share multi-container definitions
Docker
 Docker Engine
 The client-server application contains Docker daemon, REST API, CLI
 Docker Machine
 A tool to launch Docker hosts on multiple platforms
 Docker Client
 Command-line interface to interact with Docker daemons
 Docker Hub
 Repository for Docker Images
 Docker Store
 A storefront for official Docker images and plugins as well as licensed products
Docker Engine
Docker Architecture
docker run
 docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
 -d -> detached
 -t -> allocate a pseudo-tty
 -i -> keep STDIN open even if not attached
 --name -> container name
 --rm -> delete container when it exists
 -P [--publish-all] -> publish exposed ports to random ports
 -p [-publish] -> publish a container’s ports to the host
Docker Images Layers
 Layers are read only
 An image is a collection of files and some
meta data
 Images are comprised of multiple layers
 A layer is also contains software you want to
run
 Each image contains a base layer
 Docker uses a copy on write systems
Docker layers
docker image history <container-id>
Docker Sharing Layers
 Images can share layers in order to speed up transfer times and optimize disk and
memory usage
 Parent images that already exists on the host do not have to be downloaded
Docker pull / push
 docker pull [OPTIONS] NAME[:TAG]
 Pull an image or a repository from a registry (e.g. Docker Hub)
 docker push [OPTIONS] NAME[:TAG]
 Push an image or a repository from a registry (e.g. Docker Hub)
save / load / export / import
 docker save [OPTIONS] IMAGE [IMAGE]
 Save one or more images to a tar archive registry (e.g. Docker Hub)
 docker load [OPTIONS] NAME[:TAG]
 Load an image from a tar archive or STDIN
 docker export [OPTIONS] CONTAINER
 Export a container’s filesystem as a tar archive
 docker import [OPTIONS]
 Import the contents from a tarball to create a filesystem image
Docker commit
 docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
 -m Commit message
 -p Pause container during commit
 -c Apply Dockerfile instruction to the created image
 docker commit -m `message` <container-id> <container-name>:<version>
Docker flatten
docker export <container> | docker import - <image>
- Experiental flag
--squash
Docker flatten
Docker
Volumes
Volumes
 docker volume ls
 docker run –v
 -v [--volume]
 -m [--mount]
Networking
 IPAM (IP address management)
 Planning, tracking and managing IP addressess within the network
 IPAM has DNS and DHCP services
docker inspect -f='{{json .Containers}}’ <network>
docker inspect --format='{{.NetworkSettings.IPAddress}}’ <network>
Network drivers
 bridge
 Standalone containers that need to communicate
 none
 Disable all networking
 host
 Use the host’s networking directly (swarm services)
 overlay
 distributed network among multiple Docker daemon hosts
 Links
 Legacy container links
Portainer
 Docker UI
 „The easiest way to manage docker”
 https://www.portainer.io/
Portainer
 https://portainer.io/overview.html
 Detailed overview
 Containers (List, Details, Stats, Logs, Console, Creation)
 Images (List, Details)
 Network (List)
 Volumes (List)
 Container Templates
 Cluster overview
 Services Management
 Endpoint Management
 User Management and User Access Control
Portainer
Portainer
docker volume create portainer_data
docker run –name=portainer
-d -p 9000:9000
-v /var/run/docker.sock:/var/run/docker.sock
-v /opt/portainer:/data
portainer/portainer
Kitematic
 Visual Docker Container Management on Mac & Windows
 Run containers through a simple, yet powerful graphical user interface.
 https://kitematic.com/
Kitematic
 Fast and Easy Setup
 Docker Hub Integration
 Seamless Experience Between CLI and GUI
 Advantaged Features
 Automatically map ports
 Configuring volumes
 Change environment variables
 Streamline logs
 CLI access to containers
Kitematic
Docker Desktop for Windows
 Docker Desktop for Windows is the best way to get started with Docker on
Windows
 https://docs.docker.com/docker-for-windows/
 Auto update capability
 No additional software required, e.g. Virtualbox
 Windows: Hyper-V VM
 Better networking and filesystem mounting/notification
 Requires Windows 10 64-bit (Yosemite 10.10+)
 Legacy desktop solution boundled with Docker Toolbox.
Docker for AWS/Azure
 Amazon Web Services
 Amazon CloudFormation templates
 Integrated with Autoscaling, ELB, EBS
 Azure
 Integrated with VM Scale Sets for autoscaling, Azure Load Balancer, Azure Storage
Dockerfile
 FROM – Docker base
 FROM alpine:latest
 LABEL – extra information
 LABEL maintainer = ‘”Andrzej Sydor”
 COPY/ADD
 COPY build/app.jar /etc/app.jar
 ADD http://resource/files/html.tar.gz /usr/share/nginx/
 RUN – commands to install software and run scripts
 RUN mkdir –p /tmp/myapp/
 EXPOSE – the port and the protocol exposed in runtime
 EXPOSE 80/tcp
 ENTRYPOINT/CMD
 USER / WORKDIR / ENV
Dockerfile
FROM ubuntu:18.04
COPY . /app
RUN make /app
CMD python /app/app.py
Docker Build
 docker image build –file <Dockerfile> --tag <REPO>:<TAG>
 <REPO> - typically username on Docker Hub
 <TAG> - unique container value
 docker image build --tag local:dockerfile-example .
 .(dot) – current folder
Docker – Environmental variables
 ARG <key>[=<default value>]
 Build time arguments ( --build-arg <key>=<value> )
 ENV <key> <value>
 ENV <key>=<value>
 Environmental variables
Dockerfile
FROM alpine
ARG var="Default Hello World!"
ENV ENV1=$var
RUN echo "Build value: $ENV1"
ENTRYPOINT echo "Runtime value: $ENV1"
Docker env
docker build -t env-image .
docker run -d --name env-app env-image
docker logs env-app
docker run -d --name env-app2 -e ENV1=‘cmd env' env-image
docker logs env-app2
Multi-stage Dockerfile
# first stage
FROM node:10 AS builder
WORKDIR /app
RUN npm install -g @angular/cli
RUN ng new my-app --routing=true --style=css --skipGit=true --minimal=true
WORKDIR /app/my-app
RUN ng build --prod
# second stage
FROM nginx
COPY --from=builder /app/my-app/dist/my-app/ /usr/share/nginx/html
Docker Compose
 Tool for defining and running multi-container Docker applications
 YAML configuration (docker-compose.yml)
 Features:
 Multiple isolated environments on a single host
 Preserve volume data when containers are created
 Only recreate containers that have changed
 Variables and moving a composition between environments
Docker Compose
version: ‘3'
services:
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/code
redis:
image: redis
Docker Compose
docker-compose up –d --build
docker-compose stop
docker-compose rm -f
Demo
version: '3'
services:
web1:
...
web2:
...
networks:
- net1
curl:
...
networks:
- net1
networks:
net1:
curl
web1
web2
Storing images
 Docker Registry
Docker Hub
Docker Store
Docker Registry
 Service that storing your Docker images
 Open source – Apache license
 Tightly control where your images are being stored
 Fully own your images distribution pipeline
 Integrate image storage and distribution tightly into your in-house development
Filesystem
/var/lib/registry
Docker Registry
docker run -d -p 5000:5000 --name registry registry:2
docker image tag alpine localhost:5000/myfirstimage
docker push localhost:5000/myfirstimage
docker pull localhost:5000/myfirstimage
docker container stop registry &&
docker container rm -v registry
Docker Hub
 Docker Hub
 Free for public images
 Organizations
 Repository
 Automated build (GitHub, BitBucket)
Docker HUB
 docker login
 docker build --tag username/my-container:latest
.
 docker image push username/my-container:latest
Docker Store
 Docker Store
 Docker images and plugins
 Docker Certified
Third-party registries
 Red Hat Container Catalog
 OpenShift
 Jfrog
 Quay.io
 Amazon EC2 Container Registry
 Others: Microbadger e.g. inspect image
Java Maven / Gradle plugins
 Maven plugin
 https://dmp.fabric8.io/
 https://github.com/spotify/docker-maven-plugin
 Gradle plugin
 https://bmuschko.github.io/gradle-docker-plugin/
Docker – CPU/Memory
 By default, a container can consume all available resources on the host machine if it
requires it
 Limit CPU usage
 -c / --cpu-shares=1024
 --cpu-period=25000 (microseconds)
 --cpu-quota=25000 (microseconds)
 Limit memory usage
 --memory 1024M
 --memory-swap 1024M
 By default, when you set --memory, docker will set the --memory-swap size twice
 --kernel-swap 1024M
Java 10
Docker – CPU/Memory - examples
docker container inspect <container> | grep -i memory
docker container run -d --name <container> --cpu-shares 512 --memory 128M <image>
docker container update --cpu-shares 512 --memory 256M <image>
docker container update --cpu-shares 512 --memory 128M --memory-swap 256M <image>
Docker - best practices
 One application per container
 Only install what you need
 Review who has access to your Docker hosts
 Use the latest version
 Use the resources
 Awesome docker
 https://awesome-docker.netlify.com/
 https://github.com/veggiemonk/awesome-docker
Look for minimal images !?
Image Size
openjdk:8 625MB
openjdk:8-jre 470MB
openjdk:8-jre-slim 204MB
openjdk:8-jre-alpine 85MB
Use Caching Effectively
FROM ubuntu
COPY . /app
RUN apt-get update
RUN apt-get -y install openjdk-8-jdk
COPY . /app
CMD [‘java’, ‘-jar’, ‘/app/target/app.jar’]
Single / Multi line variables
FROM alpine
ENV var1=abc
ENV var2=def
FROM alpine
ENV var1=abc 
var2=def
Single / Multi line variables
FROM ubuntu
RUN wget tomcat.zip
RUN unzip tomcat.zip
RUN rm tomcat.zip
FROM alpine
RUN wget tomcat.zip 
unzip tomat.zip 
rm tomcat.zip
32 MB 21 MB
Tools
 cAdvisor https://github.com/google/cadvisor/
 Analyzes resource usage and performance characteristics of running containers
 Node-exporter https://github.com/prometheus/node_exporter/
 Exporter for machine metrics http://prometheus.io/
 Prometheus https://prometheus.io/
 Power your metrics and alerting with a leading open-source monitoring solution
 Grafana https://grafana.com/
 The open platform for beautiful analytics and monitoring
To Be Continued …
- Docker internals
 cgroups
 Limiting the resources that can be used by a processes
 namespaces
 Isolating filesystem resources
 unionFS
 Resource Management / Implicite sharing
To Be Continued …
- Docker Security
 The Docker Bench Security is a script that checks for dozens of common best-
practices around deploying Docker containers in production
 Docker Security Scanning
Q/A

Mais conteúdo relacionado

Mais procurados

Docker fundamentals
Docker fundamentalsDocker fundamentals
Docker fundamentalsAlper Unal
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshopRuncy Oommen
 
Docker and the Container Ecosystem
Docker and the Container EcosystemDocker and the Container Ecosystem
Docker and the Container Ecosystempsconnolly
 
Docker Understanding, What is Docker? Why Docker? How do I containerize somet...
Docker Understanding, What is Docker? Why Docker? How do I containerize somet...Docker Understanding, What is Docker? Why Docker? How do I containerize somet...
Docker Understanding, What is Docker? Why Docker? How do I containerize somet...Yogesh Wadile
 
Docker introduction for the beginners
Docker introduction for the beginnersDocker introduction for the beginners
Docker introduction for the beginnersJuneyoung Oh
 
Docker Command Line, Using and Choosing containers
Docker Command Line, Using and Choosing containers Docker Command Line, Using and Choosing containers
Docker Command Line, Using and Choosing containers Will Hall
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to DockerKuan Yen Heng
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basicsWalid Ashraf
 
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...Edureka!
 
Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14Simon Storm
 
Docker workshop
Docker workshopDocker workshop
Docker workshopEvans Ye
 
Docker puebla bday #4 celebration
Docker puebla bday #4 celebrationDocker puebla bday #4 celebration
Docker puebla bday #4 celebrationRamon Morales
 
Containerzation with Docker
Containerzation with DockerContainerzation with Docker
Containerzation with DockerAbdimuna Muna
 
Architecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based DeploymentsArchitecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based DeploymentsBen Hall
 
Devoxx France 2015 - The Docker Orchestration Ecosystem on Azure
Devoxx France 2015 - The Docker Orchestration Ecosystem on AzureDevoxx France 2015 - The Docker Orchestration Ecosystem on Azure
Devoxx France 2015 - The Docker Orchestration Ecosystem on AzurePatrick Chanezon
 
Docker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken CochraneDocker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken CochranedotCloud
 

Mais procurados (20)

Docker fundamentals
Docker fundamentalsDocker fundamentals
Docker fundamentals
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshop
 
Docker and the Container Ecosystem
Docker and the Container EcosystemDocker and the Container Ecosystem
Docker and the Container Ecosystem
 
Docker Understanding, What is Docker? Why Docker? How do I containerize somet...
Docker Understanding, What is Docker? Why Docker? How do I containerize somet...Docker Understanding, What is Docker? Why Docker? How do I containerize somet...
Docker Understanding, What is Docker? Why Docker? How do I containerize somet...
 
Docker introduction for the beginners
Docker introduction for the beginnersDocker introduction for the beginners
Docker introduction for the beginners
 
Docker Command Line, Using and Choosing containers
Docker Command Line, Using and Choosing containers Docker Command Line, Using and Choosing containers
Docker Command Line, Using and Choosing containers
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Docker
DockerDocker
Docker
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basics
 
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
 
Docker tutorial
Docker tutorialDocker tutorial
Docker tutorial
 
Introduction To Docker
Introduction To  DockerIntroduction To  Docker
Introduction To Docker
 
How to _docker
How to _dockerHow to _docker
How to _docker
 
Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14
 
Docker workshop
Docker workshopDocker workshop
Docker workshop
 
Docker puebla bday #4 celebration
Docker puebla bday #4 celebrationDocker puebla bday #4 celebration
Docker puebla bday #4 celebration
 
Containerzation with Docker
Containerzation with DockerContainerzation with Docker
Containerzation with Docker
 
Architecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based DeploymentsArchitecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based Deployments
 
Devoxx France 2015 - The Docker Orchestration Ecosystem on Azure
Devoxx France 2015 - The Docker Orchestration Ecosystem on AzureDevoxx France 2015 - The Docker Orchestration Ecosystem on Azure
Devoxx France 2015 - The Docker Orchestration Ecosystem on Azure
 
Docker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken CochraneDocker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken Cochrane
 

Semelhante a Docker for developers z java

Docker and containers - Presentation Slides by Priyadarshini Anand
Docker and containers - Presentation Slides by Priyadarshini AnandDocker and containers - Presentation Slides by Priyadarshini Anand
Docker and containers - Presentation Slides by Priyadarshini AnandPRIYADARSHINI ANAND
 
Develop with docker 2014 aug
Develop with docker 2014 augDevelop with docker 2014 aug
Develop with docker 2014 augVincent De Smet
 
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local BengaluruDeploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local BengaluruSwaminathan Vetri
 
Docker
DockerDocker
DockerNarato
 
Docker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps DevelopmentDocker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps Developmentmsyukor
 
Docker for .NET Developers
Docker for .NET DevelopersDocker for .NET Developers
Docker for .NET DevelopersTaswar Bhatti
 
Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020CloudHero
 
Docker in practice
Docker in practiceDocker in practice
Docker in practiceGeert Pante
 
Deployment Automation with Docker
Deployment Automation with DockerDeployment Automation with Docker
Deployment Automation with DockerEgor Pushkin
 
Continuous Integration with Docker on AWS
Continuous Integration with Docker on AWSContinuous Integration with Docker on AWS
Continuous Integration with Docker on AWSAndrew Heifetz
 
IBM WebSphere Application Server traditional and Docker
IBM WebSphere Application Server traditional and DockerIBM WebSphere Application Server traditional and Docker
IBM WebSphere Application Server traditional and DockerDavid Currie
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 applicationRoman Rodomansky
 
Running the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerRunning the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerGuido Schmutz
 
Setup docker on existing application
Setup docker on existing applicationSetup docker on existing application
Setup docker on existing applicationLuc Juggery
 

Semelhante a Docker for developers z java (20)

Docker and containers - Presentation Slides by Priyadarshini Anand
Docker and containers - Presentation Slides by Priyadarshini AnandDocker and containers - Presentation Slides by Priyadarshini Anand
Docker and containers - Presentation Slides by Priyadarshini Anand
 
Develop with docker 2014 aug
Develop with docker 2014 augDevelop with docker 2014 aug
Develop with docker 2014 aug
 
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local BengaluruDeploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
 
Docker
DockerDocker
Docker
 
Docker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps DevelopmentDocker: A New Way to Turbocharging Your Apps Development
Docker: A New Way to Turbocharging Your Apps Development
 
Docker for .NET Developers
Docker for .NET DevelopersDocker for .NET Developers
Docker for .NET Developers
 
Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020Docker Essentials Workshop— Innovation Labs July 2020
Docker Essentials Workshop— Innovation Labs July 2020
 
Docker in practice
Docker in practiceDocker in practice
Docker in practice
 
Deployment Automation with Docker
Deployment Automation with DockerDeployment Automation with Docker
Deployment Automation with Docker
 
Docker
DockerDocker
Docker
 
Docking with Docker
Docking with DockerDocking with Docker
Docking with Docker
 
Docker for Developers
Docker for DevelopersDocker for Developers
Docker for Developers
 
Docker introduction - Part 1
Docker introduction - Part 1Docker introduction - Part 1
Docker introduction - Part 1
 
Docker how to
Docker how toDocker how to
Docker how to
 
Continuous Integration with Docker on AWS
Continuous Integration with Docker on AWSContinuous Integration with Docker on AWS
Continuous Integration with Docker on AWS
 
IBM WebSphere Application Server traditional and Docker
IBM WebSphere Application Server traditional and DockerIBM WebSphere Application Server traditional and Docker
IBM WebSphere Application Server traditional and Docker
 
Dockerizing a Symfony2 application
Dockerizing a Symfony2 applicationDockerizing a Symfony2 application
Dockerizing a Symfony2 application
 
Running the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker ContainerRunning the Oracle SOA Suite Environment in a Docker Container
Running the Oracle SOA Suite Environment in a Docker Container
 
Setup docker on existing application
Setup docker on existing applicationSetup docker on existing application
Setup docker on existing application
 
Docker team training
Docker team trainingDocker team training
Docker team training
 

Último

Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxraffaeleoman
 
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfSOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfMahamudul Hasan
 
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfThe workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfSenaatti-kiinteistöt
 
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalDigital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalFabian de Rijk
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaKayode Fayemi
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoKayode Fayemi
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatmentnswingard
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lodhisaajjda
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Baileyhlharris
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIINhPhngng3
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...amilabibi1
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar TrainingKylaCullinane
 
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...David Celestin
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfSkillCertProExams
 

Último (15)

Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
 
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfSOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
 
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfThe workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
 
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalDigital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of Drupal
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
 
ICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdfICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdf
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatment
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Bailey
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio III
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar Training
 
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
 

Docker for developers z java

  • 2. Agenda  Docker introduction  Containers: run, start, stop, rm, ps  Images: pull, push, import, export, save, load  Networking  Volumes  UI tools  Dockerfile  Docker Compose  Best practices
  • 3. Docker  Docker is the leading software container platform  Founded in 2013 as Linux developer tool  Fundamentally solves the „works on my machine” problem  Container industry inventor, leader and innovative  Transform app and infrastructure security, portability, agility and efficiency
  • 4. One Application on One Physical Server  Limitations  Slow development times  Huge costs  Wasted resources  Difficult to scale  Difficult to migrate  Vendor lock in
  • 5. Hypervisior – Based Virtualization  Benefit:  Better resource pooling  One physical machine divided into multiple virtual machines  Easier to scale  VMs in the cloud  Rapid elasticity  Pay as you go model  Limitations:  Each VM stills requires:  CPU limitations  Storage  RAM  An entire guest operating system  Full guest OS means wasted resources  Application portability not guaranteed
  • 6. Docker  Standarized packaging for software and dependencies  Isolate apps from each other  Share the same OS kernel  Works with all major Linux and Windows Server
  • 7.
  • 8. Key Benefits of Docker Containers  Speed  No OS to boot – applications online in seconds  Portability  Less dependencies between proces layers = ability to move between infrastructure  Efficiency  Less OS overhead  Improved resource efficiency
  • 9. WORA / PODA / CaaS  WORA = Write Once Run Anywhere {J,W,E}AR  PODA = Package Once Deploy Anywhere  CaaS = Container as a Service
  • 10. Docker  Image  The basis of a Docker container  Container  The image when it is ‚running’  Registry  Stores, distributes and manages Docker images  Dockerfile  Commands to assemble an image  Docker Compose  Define and share multi-container definitions
  • 11. Docker  Docker Engine  The client-server application contains Docker daemon, REST API, CLI  Docker Machine  A tool to launch Docker hosts on multiple platforms  Docker Client  Command-line interface to interact with Docker daemons  Docker Hub  Repository for Docker Images  Docker Store  A storefront for official Docker images and plugins as well as licensed products
  • 14. docker run  docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]  -d -> detached  -t -> allocate a pseudo-tty  -i -> keep STDIN open even if not attached  --name -> container name  --rm -> delete container when it exists  -P [--publish-all] -> publish exposed ports to random ports  -p [-publish] -> publish a container’s ports to the host
  • 15.
  • 16. Docker Images Layers  Layers are read only  An image is a collection of files and some meta data  Images are comprised of multiple layers  A layer is also contains software you want to run  Each image contains a base layer  Docker uses a copy on write systems
  • 17. Docker layers docker image history <container-id>
  • 18. Docker Sharing Layers  Images can share layers in order to speed up transfer times and optimize disk and memory usage  Parent images that already exists on the host do not have to be downloaded
  • 19. Docker pull / push  docker pull [OPTIONS] NAME[:TAG]  Pull an image or a repository from a registry (e.g. Docker Hub)  docker push [OPTIONS] NAME[:TAG]  Push an image or a repository from a registry (e.g. Docker Hub)
  • 20. save / load / export / import  docker save [OPTIONS] IMAGE [IMAGE]  Save one or more images to a tar archive registry (e.g. Docker Hub)  docker load [OPTIONS] NAME[:TAG]  Load an image from a tar archive or STDIN  docker export [OPTIONS] CONTAINER  Export a container’s filesystem as a tar archive  docker import [OPTIONS]  Import the contents from a tarball to create a filesystem image
  • 21. Docker commit  docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]  -m Commit message  -p Pause container during commit  -c Apply Dockerfile instruction to the created image  docker commit -m `message` <container-id> <container-name>:<version>
  • 22.
  • 23. Docker flatten docker export <container> | docker import - <image> - Experiental flag --squash
  • 26. Volumes  docker volume ls  docker run –v  -v [--volume]  -m [--mount]
  • 27.
  • 28. Networking  IPAM (IP address management)  Planning, tracking and managing IP addressess within the network  IPAM has DNS and DHCP services docker inspect -f='{{json .Containers}}’ <network> docker inspect --format='{{.NetworkSettings.IPAddress}}’ <network>
  • 29. Network drivers  bridge  Standalone containers that need to communicate  none  Disable all networking  host  Use the host’s networking directly (swarm services)  overlay  distributed network among multiple Docker daemon hosts  Links  Legacy container links
  • 30.
  • 31. Portainer  Docker UI  „The easiest way to manage docker”  https://www.portainer.io/
  • 32. Portainer  https://portainer.io/overview.html  Detailed overview  Containers (List, Details, Stats, Logs, Console, Creation)  Images (List, Details)  Network (List)  Volumes (List)  Container Templates  Cluster overview  Services Management  Endpoint Management  User Management and User Access Control
  • 34. Portainer docker volume create portainer_data docker run –name=portainer -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v /opt/portainer:/data portainer/portainer
  • 35. Kitematic  Visual Docker Container Management on Mac & Windows  Run containers through a simple, yet powerful graphical user interface.  https://kitematic.com/
  • 36. Kitematic  Fast and Easy Setup  Docker Hub Integration  Seamless Experience Between CLI and GUI  Advantaged Features  Automatically map ports  Configuring volumes  Change environment variables  Streamline logs  CLI access to containers
  • 38. Docker Desktop for Windows  Docker Desktop for Windows is the best way to get started with Docker on Windows  https://docs.docker.com/docker-for-windows/  Auto update capability  No additional software required, e.g. Virtualbox  Windows: Hyper-V VM  Better networking and filesystem mounting/notification  Requires Windows 10 64-bit (Yosemite 10.10+)  Legacy desktop solution boundled with Docker Toolbox.
  • 39. Docker for AWS/Azure  Amazon Web Services  Amazon CloudFormation templates  Integrated with Autoscaling, ELB, EBS  Azure  Integrated with VM Scale Sets for autoscaling, Azure Load Balancer, Azure Storage
  • 40. Dockerfile  FROM – Docker base  FROM alpine:latest  LABEL – extra information  LABEL maintainer = ‘”Andrzej Sydor”  COPY/ADD  COPY build/app.jar /etc/app.jar  ADD http://resource/files/html.tar.gz /usr/share/nginx/  RUN – commands to install software and run scripts  RUN mkdir –p /tmp/myapp/  EXPOSE – the port and the protocol exposed in runtime  EXPOSE 80/tcp  ENTRYPOINT/CMD  USER / WORKDIR / ENV
  • 41. Dockerfile FROM ubuntu:18.04 COPY . /app RUN make /app CMD python /app/app.py
  • 42. Docker Build  docker image build –file <Dockerfile> --tag <REPO>:<TAG>  <REPO> - typically username on Docker Hub  <TAG> - unique container value  docker image build --tag local:dockerfile-example .  .(dot) – current folder
  • 43. Docker – Environmental variables  ARG <key>[=<default value>]  Build time arguments ( --build-arg <key>=<value> )  ENV <key> <value>  ENV <key>=<value>  Environmental variables
  • 44. Dockerfile FROM alpine ARG var="Default Hello World!" ENV ENV1=$var RUN echo "Build value: $ENV1" ENTRYPOINT echo "Runtime value: $ENV1"
  • 45. Docker env docker build -t env-image . docker run -d --name env-app env-image docker logs env-app docker run -d --name env-app2 -e ENV1=‘cmd env' env-image docker logs env-app2
  • 46.
  • 47. Multi-stage Dockerfile # first stage FROM node:10 AS builder WORKDIR /app RUN npm install -g @angular/cli RUN ng new my-app --routing=true --style=css --skipGit=true --minimal=true WORKDIR /app/my-app RUN ng build --prod # second stage FROM nginx COPY --from=builder /app/my-app/dist/my-app/ /usr/share/nginx/html
  • 48.
  • 49. Docker Compose  Tool for defining and running multi-container Docker applications  YAML configuration (docker-compose.yml)  Features:  Multiple isolated environments on a single host  Preserve volume data when containers are created  Only recreate containers that have changed  Variables and moving a composition between environments
  • 50. Docker Compose version: ‘3' services: web: build: . ports: - "5000:5000" volumes: - .:/code redis: image: redis
  • 51. Docker Compose docker-compose up –d --build docker-compose stop docker-compose rm -f
  • 53. Storing images  Docker Registry Docker Hub Docker Store
  • 54. Docker Registry  Service that storing your Docker images  Open source – Apache license  Tightly control where your images are being stored  Fully own your images distribution pipeline  Integrate image storage and distribution tightly into your in-house development Filesystem /var/lib/registry
  • 55. Docker Registry docker run -d -p 5000:5000 --name registry registry:2 docker image tag alpine localhost:5000/myfirstimage docker push localhost:5000/myfirstimage docker pull localhost:5000/myfirstimage docker container stop registry && docker container rm -v registry
  • 56. Docker Hub  Docker Hub  Free for public images  Organizations  Repository  Automated build (GitHub, BitBucket)
  • 57. Docker HUB  docker login  docker build --tag username/my-container:latest .  docker image push username/my-container:latest
  • 58. Docker Store  Docker Store  Docker images and plugins  Docker Certified
  • 59. Third-party registries  Red Hat Container Catalog  OpenShift  Jfrog  Quay.io  Amazon EC2 Container Registry  Others: Microbadger e.g. inspect image
  • 60. Java Maven / Gradle plugins  Maven plugin  https://dmp.fabric8.io/  https://github.com/spotify/docker-maven-plugin  Gradle plugin  https://bmuschko.github.io/gradle-docker-plugin/
  • 61. Docker – CPU/Memory  By default, a container can consume all available resources on the host machine if it requires it  Limit CPU usage  -c / --cpu-shares=1024  --cpu-period=25000 (microseconds)  --cpu-quota=25000 (microseconds)  Limit memory usage  --memory 1024M  --memory-swap 1024M  By default, when you set --memory, docker will set the --memory-swap size twice  --kernel-swap 1024M Java 10
  • 62. Docker – CPU/Memory - examples docker container inspect <container> | grep -i memory docker container run -d --name <container> --cpu-shares 512 --memory 128M <image> docker container update --cpu-shares 512 --memory 256M <image> docker container update --cpu-shares 512 --memory 128M --memory-swap 256M <image>
  • 63. Docker - best practices  One application per container  Only install what you need  Review who has access to your Docker hosts  Use the latest version  Use the resources  Awesome docker  https://awesome-docker.netlify.com/  https://github.com/veggiemonk/awesome-docker
  • 64. Look for minimal images !? Image Size openjdk:8 625MB openjdk:8-jre 470MB openjdk:8-jre-slim 204MB openjdk:8-jre-alpine 85MB
  • 65. Use Caching Effectively FROM ubuntu COPY . /app RUN apt-get update RUN apt-get -y install openjdk-8-jdk COPY . /app CMD [‘java’, ‘-jar’, ‘/app/target/app.jar’]
  • 66. Single / Multi line variables FROM alpine ENV var1=abc ENV var2=def FROM alpine ENV var1=abc var2=def
  • 67. Single / Multi line variables FROM ubuntu RUN wget tomcat.zip RUN unzip tomcat.zip RUN rm tomcat.zip FROM alpine RUN wget tomcat.zip unzip tomat.zip rm tomcat.zip 32 MB 21 MB
  • 68. Tools  cAdvisor https://github.com/google/cadvisor/  Analyzes resource usage and performance characteristics of running containers  Node-exporter https://github.com/prometheus/node_exporter/  Exporter for machine metrics http://prometheus.io/  Prometheus https://prometheus.io/  Power your metrics and alerting with a leading open-source monitoring solution  Grafana https://grafana.com/  The open platform for beautiful analytics and monitoring
  • 69. To Be Continued … - Docker internals  cgroups  Limiting the resources that can be used by a processes  namespaces  Isolating filesystem resources  unionFS  Resource Management / Implicite sharing
  • 70. To Be Continued … - Docker Security  The Docker Bench Security is a script that checks for dozens of common best- practices around deploying Docker containers in production  Docker Security Scanning
  • 71. Q/A

Notas do Editor

  1. Wynalazca branży kontenerowej, lider i innowator Przekształć bezpieczeństwo aplikacji i infrastruktury, przenośność, zwinność i wydajność
  2. Przemyśleś Docker Swarm czy tutaj ma być?
  3. https://docs.docker.com/engine/docker-overview/
  4. https://docs.docker.com/engine/docker-overview/#docker-architecture
  5. Obrazy składają się z wielu warstw
  6. save/load -> images Export/import -> container https://tuhrig.de/difference-between-save-and-export-in-docker/ https://docs.docker.com/engine/reference/commandline/save/ https://docs.docker.com/engine/reference/commandline/load/
  7. Flatten a Docker container So it is only possible to “flatten” a Docker container, not an image. So we need to start a container from an image first. Then we can export and import the container in one line: 1 docker export <CONTAINER ID> | docker import - some-image-name:latest
  8. Flatten a Docker container So it is only possible to “flatten” a Docker container, not an image. So we need to start a container from an image first. Then we can export and import the container in one line: 1 docker export <CONTAINER ID> | docker import - some-image-name:latest
  9. -volumes not being used by any container docker volume ls -f dangling=true   docker volume prune   -volumes-from <containerId>   *removing docker rm -v <containerId>   docker volume rm <volumeName>   volume inspect <volumeName>       docker volume create myVolume docker run -dit --name alpine1 -v myVolume:/volume alpine
  10. docker network create my-network docker network ls docker network inspect mysql_default docker network prune Docker container run … --network my-network
  11. https://docs.docker.com/network/ Podłączenie kontenera do sieci typu bridge spowoduję, że kontenery będące w tej samej sieci będą się mogły pingować a kontenery będące w innych sieciach już nie. Podłączenie kontenera do sieci none spowoduję, że kontener będzie miał tylko interfejs pętli zwrotnej loopback. Podłączenie kontenera do sieci host powoduję, że będzie on współdzielił porty i adresy IP hosta. https://docs.docker.com/network/bridge/
  12. FROM <image>:<tag> MAINTAINER WORKDIR ADD <source path or URL> <destination path> (copy the files from the source into the containers) COPY <source path or URL> <destination path> (copy new files of directories>   As you can see, the functionality of COPY is almost the same as the ADD instruction, with one difference. COPY supports only the basic copying of local files into the container. On the other hand, ADD gives some more features, such as archive extraction, downloading files through URL, and so on. Docker's best practices say that you should prefer COPY if you do not need those additional features of ADD. The Dockerfile will be cleaner and easier to understand thanks to the transparency of the COPY command.   RUN CMD command parameter1 parameterN ENTRYPOINT EXPOSE VOLUME LABEL ENV USER ARG ONBUILD [144] Let's summarize what we have learned about the differences and their cooperation: A Dockerfile should specify at least one CMD or ENTRYPOINT instruction Only the last CMD and ENTRYPOINT in a Dockerfile will be used ENTRYPOINT should be defined when using the container as an executable You should use the CMD instruction as a way of defining default arguments for the command defined as ENTRYPOINT or for executing an ad-hoc command in a container CMD will be overridden when running the container with alternative arguments ENTRYPOINT sets the concrete default application that is used every time a container is created using the image If you couple ENTRYPOINT with CMD, you can remove an executable from CMD and just leave its arguments which will be passed to ENTRYPOINT The best use for ENTRYPOINT is to set the image's main command, allowing that image to be run as though it was that command (and then use CMD as the default flags)
  13. FROM <image>:<tag> MAINTAINER WORKDIR ADD <source path or URL> <destination path> (copy the files from the source into the containers) COPY <source path or URL> <destination path> (copy new files of directories>   As you can see, the functionality of COPY is almost the same as the ADD instruction, with one difference. COPY supports only the basic copying of local files into the container. On the other hand, ADD gives some more features, such as archive extraction, downloading files through URL, and so on. Docker's best practices say that you should prefer COPY if you do not need those additional features of ADD. The Dockerfile will be cleaner and easier to understand thanks to the transparency of the COPY command.   RUN CMD command parameter1 parameterN ENTRYPOINT EXPOSE VOLUME LABEL ENV USER ARG ONBUILD [144] Let's summarize what we have learned about the differences and their cooperation: A Dockerfile should specify at least one CMD or ENTRYPOINT instruction Only the last CMD and ENTRYPOINT in a Dockerfile will be used ENTRYPOINT should be defined when using the container as an executable You should use the CMD instruction as a way of defining default arguments for the command defined as ENTRYPOINT or for executing an ad-hoc command in a container CMD will be overridden when running the container with alternative arguments ENTRYPOINT sets the concrete default application that is used every time a container is created using the image If you couple ENTRYPOINT with CMD, you can remove an executable from CMD and just leave its arguments which will be passed to ENTRYPOINT The best use for ENTRYPOINT is to set the image's main command, allowing that image to be run as though it was that command (and then use CMD as the default flags)