SlideShare a Scribd company logo
FORFOR
(JAVA)(JAVA) DEVELOPERSDEVELOPERS
RAFAEL BENEVIDES
@RAFABENE@RAFABENE
1. Docker concepts
2. Creating docker hosts with docker-machine
3. Running docker
4. Creating docker images
5. Running an Application Server in Docker
6. Changing container behaviour
7. 3 ways to deploy an application
8. Composing with docker-compose
9. docker-swarm overview
10. Questions?
AGENDA
Who am I ?
My name is Rafael Benevides
I work for Red Hat since 2009
JBoss Developer Materials lead
Apache DeltaSpike PMC member
Middleware DevOps "guy"
Some facts about me
“ My work consists to help developers
worldwide to be more effective in software
development and promote tools and
practices that help them to be more
productive."e-mail: benevides@redhat.com
Twitter: @rafabene
DISCLAIMER
This presentation should take 45 minutes
It will be 80% live-coding
It won't cover "What is docker?",
"Installing docker", "Motivations to use
docker" topics
But you will see/learn how to use docker
and take you own conclusions about the
motivations to start using it.
Docker Hello world
Docker
Client
Docker
Hub
Docker Host
Daemon
Image 1
Image 2
Image 3
Image 1
Image 2
Image 3
Container 1
Container 2
docker run <image x>
docker run hello-world
docker run <image x>
unix:///var/run/docker.sock
Docker Machine
A L L O W S T H E C R E A T I O N O F D O C K E R H O S T SA L L O W S T H E C R E A T I O N O F D O C K E R H O S T S
DRIVERSDRIVERS
1. AWS - Amazon Web Services
2. Digital Ocean
3. Exoscale
4. Generic ( Fedora, RHEL, CentOS, ... )
5. GCE - Google Compute Enginer
6. IBM Softlayer
7. Microsoft Azure / Hyper-V
8. OpenStack
9. Oracle VirtualBox
10. Rackspace
11. VMware Fusion / vCloud Air / vSphere
USEFUL COMMANDSUSEFUL COMMANDS
docker-machine create -d <driver> <name>
docker-machine ls
docker env <name>
ENV VARSENV VARS
DOCKER_TLS_VERIFY
DOCKER_HOST
DOCKER_CERT_PATH
DOCKER_MACHINE_NAME
Docker commands
DOCKER RUNDOCKER RUN
Creates a new container
docker run <image> command
docker run -it <image> command
docker run --name -it <image> command
docker run --name --rm -it <image> command
docker run -d fedora /bin/bash -c "while true; do echo
hello world; sleep 1; done"
Docker commands
OT HE R DOCK ER COMMANDSOT HE R DOCK ER COMMANDS
docker ps / docker ps -a
docker stop <container> / docker stop -t=1 <container>
docker rm <container> / docker rm `docker ps -aq`
docker logs <container> / docker logs -f <container>
docker attach <container>
docker stats <container>
2 Ways to create Docker Images
COMMIT WAYCOMMIT WAY
docker commit -m "<menssage>" <image name>
docker history <image name>
DOCKERFILE WAYDOCKERFILE WAY
docker build -t <tag> <dockerfile path>
DOCKERFILE REFDOCKERFILE REF
FROM
MAINTAINER
WORKDIR
ENV
RUN
COPY
ADD
EXPOSE
VOLUME
USER
CMD
Dockerfile anatomy
# Use latest jboss/base-jdk:7 image as the base
FROM jboss/base-jdk:8
# Set the WILDFLY_VERSION env variable
ENV WILDFLY_VERSION 9.0.0.Final
# Add the WildFly distribution to /opt, and make wildfly the owner of the extracted tar content
# Make sure the distribution is available from a well-known place
RUN cd $HOME && curl http://download.jboss.org/wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.tar.gz | tar zx &
# Set the JBOSS_HOME env variable
ENV JBOSS_HOME /opt/jboss/wildfly
# Expose the ports we're interested in
EXPOSE 8080
# Set the default command to run on boot
# This will boot WildFly in the standalone mode and bind to all interface
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0"]
WildFly Image example
Changing container behaviour
CHANGING ENV VARCHANGING ENV VAR
docker run -e ...
EXPOSING PORTSEXPOSING PORTS
docker run -P ...
docker run -p <host:container> ...
docker-machine ip
MOUTING VOLUMESMOUTING VOLUMES
docker run -v <host:container> ...
3 Ways to deploy an application
1 - MOUNTING A VOLUME1 - MOUNTING A VOLUME
docker run -v <host:container> ...
2 - ADMINISTRATIVE CONSOLE2 - ADMINISTRATIVE CONSOLE
docker run -p <host:port> ...
3 - INCLUDE INSIDE THE IMAGE3 - INCLUDE INSIDE THE IMAGE
Dockerfile
ADD your-awesome-app.war /opt/jboss/wildfly/standalone/deployments/
Cluster example
Apache HTTPD
+ mod_cluster
Postgres
database
WildFly instances
Linking containers
[ jboss@22ac4068f95f ~]$ cat /etc/hosts
172.17.0.50 22ac4068f95f
127.0.0.1 localhost
172.17.0.43 db 84e9fc3e4455
172.17.0.44 modcluster 13784a898c33
Environment Variables
$DB_NAME
$DB_ENV_LANG
$DB_ENV_PG_VERSION
$DB_ENV_PGDATA
$DB_ENV_POSTGRES_PASSWORD
$DB_ENV_PG_MAJOR
$DB_ENV_POSTGRES_USER
$DB_PORT
$DB_PORT_5432_TCP
$DB_PORT_5432_TCP_PROTO
$DB_PORT_5432_TCP_ADDR
$DB_PORT_5432_TCP_PORT
$MODCLUSTER_NAME
$MODCLUSTER_PORT_80_TCP
$MODCLUSTER_PORT_80_TCP_PORT
$MODCLUSTER_PORT
$MODCLUSTER_PORT_80_TCP_ADDR
$MODCLUSTER_PORT_80_TCP_PROTO
docker run --link <container_name:alias>
Docker compose
docker-compose.yaml
db:
image: postgres
ports:
- "5432:5432"
environment:
- POSTGRES_USER=ticketmonster
- POSTGRES_PASSWORD=ticketmonster-docker
modcluster:
image: goldmann/mod_cluster
ports:
- "80:80"
wildfly:
build: ../Dockerfiles/ticketmonster/
links:
- db:db
- modcluster:modcluster
docker-compose up -d
docker-compose ps
docker-compose logs
docker-compose build
docker-compose scale <service>=x
DISCLAIMER
You're about to see an overview of docker-
swarm
Some issues found:
machine restart
cross-host linking
Docker Swarm
Discovery Services
Docker Hub
Static file
Static list
etcd
consul
zookeeper
Creating a Docker Swarm
echo "Creating cluster ..."
TOKEN=`docker run swarm create`
echo "Got the token " $TOKEN
echo "Creating Swarm master ..."
docker-machine create -d virtualbox --swarm --swarm-master
--swarm-strategy=spread
--swarm-discovery token://$TOKEN swarm-master
echo "Creating Swarm node 01 ..."
docker-machine create -d virtualbox --swarm
--swarm-discovery token://$TOKEN swarm-node-01
echo "Creating Swarm node 02 ..."
docker-machine create -d virtualbox --swarm
--swarm-discovery token://$TOKEN swarm-node-02
eval "$(docker-machine env --swarm swarm-master)"
Strategy
spread*
binpack
random
Kubernetes
Github code
https://github.com
/rafabene
/devops-demo
THANK YOU!THANK YOU!
RAFAEL BENEVIDESRAFAEL BENEVIDES
BENEVIDES@REDHAT.COMBENEVIDES@REDHAT.COM
@RAFABENE@RAFABENE

More Related Content

What's hot (20)

PDF
A Hitchhiker's Guide to Cloud Native Java EE
Mario-Leander Reimer
 
PDF
Containerizing a Web Application with Vue.js and Java
Jadson Santos
 
PDF
Kubernetes Story - Day 1: Build and Manage Containers with Podman
Mihai Criveti
 
PDF
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
謝 宗穎
 
PDF
Continuous Integration/Deployment with Docker and Jenkins
Francesco Bruni
 
PDF
Kubelet with no Kubernetes Masters | DevNation Tech Talk
Red Hat Developers
 
PPT
Python virtualenv & pip in 90 minutes
Larry Cai
 
PDF
Docker - From Walking To Running
Giacomo Vacca
 
PPTX
Learn docker in 90 minutes
Larry Cai
 
PDF
Dockerize Laravel Application
Afrimadoni Dinata
 
PPTX
Docker Command Line, Using and Choosing containers
Will Hall
 
PPTX
Baking docker using chef
Mukta Aphale
 
PDF
Deploying Apache Kylin on AWS and designing a task scheduler for it
Chase Zhang
 
PPTX
Vagrant introduction for Developers
Antons Kranga
 
PDF
Continuous Integration and Kamailio
Giacomo Vacca
 
PDF
Docker in production: reality, not hype (OSCON 2015)
bridgetkromhout
 
PDF
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Ontico
 
PDF
Using Kubernetes for Continuous Integration and Continuous Delivery
Carlos Sanchez
 
PDF
Docker Continuous Delivery Workshop
Jirayut Nimsaeng
 
PPTX
Delivering eBay's CI Solution with Apache Mesos & Docker - DockerCon 2014
ahunnargikar
 
A Hitchhiker's Guide to Cloud Native Java EE
Mario-Leander Reimer
 
Containerizing a Web Application with Vue.js and Java
Jadson Santos
 
Kubernetes Story - Day 1: Build and Manage Containers with Podman
Mihai Criveti
 
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
謝 宗穎
 
Continuous Integration/Deployment with Docker and Jenkins
Francesco Bruni
 
Kubelet with no Kubernetes Masters | DevNation Tech Talk
Red Hat Developers
 
Python virtualenv & pip in 90 minutes
Larry Cai
 
Docker - From Walking To Running
Giacomo Vacca
 
Learn docker in 90 minutes
Larry Cai
 
Dockerize Laravel Application
Afrimadoni Dinata
 
Docker Command Line, Using and Choosing containers
Will Hall
 
Baking docker using chef
Mukta Aphale
 
Deploying Apache Kylin on AWS and designing a task scheduler for it
Chase Zhang
 
Vagrant introduction for Developers
Antons Kranga
 
Continuous Integration and Kamailio
Giacomo Vacca
 
Docker in production: reality, not hype (OSCON 2015)
bridgetkromhout
 
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Ontico
 
Using Kubernetes for Continuous Integration and Continuous Delivery
Carlos Sanchez
 
Docker Continuous Delivery Workshop
Jirayut Nimsaeng
 
Delivering eBay's CI Solution with Apache Mesos & Docker - DockerCon 2014
ahunnargikar
 

Viewers also liked (20)

PPTX
JavaEE Microservices platforms
Payara
 
PPTX
Microservices Platforms - Which is Best?
Payara
 
PDF
JavaLand 2014 - Ankor.io Presentation
manolitto
 
PDF
Joomladay Netherlands 2012 - Joomla in the Cloud
Johan Janssens
 
PPTX
JavaLand - Integration Testing How-to
Nicolas Fränkel
 
PPTX
Developing JavaEE 7 based apps with Payara Micro
Payara
 
PDF
Useful Design Patterns for Enterprise Applications with Java
PT.JUG
 
PPTX
Deploying Elastic Java EE Microservices in the Cloud with Docker
Payara
 
PPTX
JavaEE Microservices -the Payara Way
Payara
 
PPTX
Developing Java EE applications with NetBeans and Payara
Payara
 
PDF
Microservices
PT.JUG
 
PDF
Automated integration testing of distributed systems with Docker Compose and ...
Boris Kravtsov
 
PDF
Developing Microservices with Apache Camel, by Claus Ibsen
Judy Breedlove
 
PDF
Monitoring Highly Dynamic and Distributed Systems with NGINX Amplify
NGINX, Inc.
 
PDF
Continuous integration and delivery for java based web applications
Sunil Dalal
 
PDF
Integration Testing with Docker Containers with DockerCompose
Mike Holdsworth
 
PPTX
High performance java ee with j cache and cdi
Payara
 
PDF
Just enough app server
Antonio Goncalves
 
PPTX
Badass Microservices - deploy, build & scale your apps with Payara Micro
Payara
 
PPTX
JPA 2.1 on Payara Server
Payara
 
JavaEE Microservices platforms
Payara
 
Microservices Platforms - Which is Best?
Payara
 
JavaLand 2014 - Ankor.io Presentation
manolitto
 
Joomladay Netherlands 2012 - Joomla in the Cloud
Johan Janssens
 
JavaLand - Integration Testing How-to
Nicolas Fränkel
 
Developing JavaEE 7 based apps with Payara Micro
Payara
 
Useful Design Patterns for Enterprise Applications with Java
PT.JUG
 
Deploying Elastic Java EE Microservices in the Cloud with Docker
Payara
 
JavaEE Microservices -the Payara Way
Payara
 
Developing Java EE applications with NetBeans and Payara
Payara
 
Microservices
PT.JUG
 
Automated integration testing of distributed systems with Docker Compose and ...
Boris Kravtsov
 
Developing Microservices with Apache Camel, by Claus Ibsen
Judy Breedlove
 
Monitoring Highly Dynamic and Distributed Systems with NGINX Amplify
NGINX, Inc.
 
Continuous integration and delivery for java based web applications
Sunil Dalal
 
Integration Testing with Docker Containers with DockerCompose
Mike Holdsworth
 
High performance java ee with j cache and cdi
Payara
 
Just enough app server
Antonio Goncalves
 
Badass Microservices - deploy, build & scale your apps with Payara Micro
Payara
 
JPA 2.1 on Payara Server
Payara
 
Ad

Similar to Docker for (Java) Developers (20)

PDF
Work shop - an introduction to the docker ecosystem
João Pedro Harbs
 
PDF
Agile Brown Bag - Vagrant & Docker: Introduction
Agile Partner S.A.
 
PPTX
Dockerize the World - presentation from Hradec Kralove
damovsky
 
PDF
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Codemotion
 
PDF
codemotion-docker-2014
Carlo Bonamico
 
PPTX
Introduction to docker
Frederik Mogensen
 
PDF
Introduction to Docker and deployment and Azure
Jérôme Petazzoni
 
PPTX
Dockerize the World
damovsky
 
PDF
Docker From Scratch
Giacomo Vacca
 
PDF
Docker 0.11 at MaxCDN meetup in Los Angeles
Jérôme Petazzoni
 
PDF
How to Dockerize Web Application using Docker Compose
Evoke Technologies
 
PPTX
Cohesion Techsessie Docker - Daniel Palstra
Daniel Palstra
 
PDF
Docker+java
DPC Consulting Ltd
 
PDF
Docker: A New Way to Turbocharging Your Apps Development
msyukor
 
PDF
containers and virtualization tools ( Docker )
Imo Inyang
 
PPTX
Docker lightning
roadster43
 
PPTX
Developer workflow with docker
Wyn B. Van Devanter
 
PDF
Docker 101: An Introduction
POSSCON
 
PPTX
Introducing & playing with Docker | Manel Martinez | 1st Docker Crete Meetup
Alexandra Karapidaki
 
Work shop - an introduction to the docker ecosystem
João Pedro Harbs
 
Agile Brown Bag - Vagrant & Docker: Introduction
Agile Partner S.A.
 
Dockerize the World - presentation from Hradec Kralove
damovsky
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Codemotion
 
codemotion-docker-2014
Carlo Bonamico
 
Introduction to docker
Frederik Mogensen
 
Introduction to Docker and deployment and Azure
Jérôme Petazzoni
 
Dockerize the World
damovsky
 
Docker From Scratch
Giacomo Vacca
 
Docker 0.11 at MaxCDN meetup in Los Angeles
Jérôme Petazzoni
 
How to Dockerize Web Application using Docker Compose
Evoke Technologies
 
Cohesion Techsessie Docker - Daniel Palstra
Daniel Palstra
 
Docker+java
DPC Consulting Ltd
 
Docker: A New Way to Turbocharging Your Apps Development
msyukor
 
containers and virtualization tools ( Docker )
Imo Inyang
 
Docker lightning
roadster43
 
Developer workflow with docker
Wyn B. Van Devanter
 
Docker 101: An Introduction
POSSCON
 
Introducing & playing with Docker | Manel Martinez | 1st Docker Crete Meetup
Alexandra Karapidaki
 
Ad

More from Rafael Benevides (11)

PDF
JavaOne 2016: Kubernetes introduction for Java Developers
Rafael Benevides
 
PDF
Microservices with Kubernetes, Docker, and Jenkins
Rafael Benevides
 
PDF
JavaOne 2016: The Deploy Master: From Basic to Zero Downtime, Blue/Green, A/B...
Rafael Benevides
 
PDF
CDI Extensions e DeltaSpike
Rafael Benevides
 
ODP
TDC 2014 SP - E o DeltaSpike ?
Rafael Benevides
 
PDF
Reunião SouJava BSB - 2005 - Java a favor do consumidor brasileiro
Rafael Benevides
 
PDF
Apostilava Java EE 5 - 2007
Rafael Benevides
 
ODP
TDC 2012 - JDF
Rafael Benevides
 
PDF
JBossInBossa 2011 - BRMS
Rafael Benevides
 
PPT
JBossinBossa 2010 - Seam
Rafael Benevides
 
PDF
Red Hat Roadshow 2009 - Drools
Rafael Benevides
 
JavaOne 2016: Kubernetes introduction for Java Developers
Rafael Benevides
 
Microservices with Kubernetes, Docker, and Jenkins
Rafael Benevides
 
JavaOne 2016: The Deploy Master: From Basic to Zero Downtime, Blue/Green, A/B...
Rafael Benevides
 
CDI Extensions e DeltaSpike
Rafael Benevides
 
TDC 2014 SP - E o DeltaSpike ?
Rafael Benevides
 
Reunião SouJava BSB - 2005 - Java a favor do consumidor brasileiro
Rafael Benevides
 
Apostilava Java EE 5 - 2007
Rafael Benevides
 
TDC 2012 - JDF
Rafael Benevides
 
JBossInBossa 2011 - BRMS
Rafael Benevides
 
JBossinBossa 2010 - Seam
Rafael Benevides
 
Red Hat Roadshow 2009 - Drools
Rafael Benevides
 

Recently uploaded (20)

PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 

Docker for (Java) Developers

  • 2. 1. Docker concepts 2. Creating docker hosts with docker-machine 3. Running docker 4. Creating docker images 5. Running an Application Server in Docker 6. Changing container behaviour 7. 3 ways to deploy an application 8. Composing with docker-compose 9. docker-swarm overview 10. Questions? AGENDA
  • 3. Who am I ? My name is Rafael Benevides I work for Red Hat since 2009 JBoss Developer Materials lead Apache DeltaSpike PMC member Middleware DevOps "guy" Some facts about me “ My work consists to help developers worldwide to be more effective in software development and promote tools and practices that help them to be more productive."e-mail: [email protected] Twitter: @rafabene
  • 4. DISCLAIMER This presentation should take 45 minutes It will be 80% live-coding It won't cover "What is docker?", "Installing docker", "Motivations to use docker" topics But you will see/learn how to use docker and take you own conclusions about the motivations to start using it.
  • 5. Docker Hello world Docker Client Docker Hub Docker Host Daemon Image 1 Image 2 Image 3 Image 1 Image 2 Image 3 Container 1 Container 2 docker run <image x> docker run hello-world docker run <image x> unix:///var/run/docker.sock
  • 6. Docker Machine A L L O W S T H E C R E A T I O N O F D O C K E R H O S T SA L L O W S T H E C R E A T I O N O F D O C K E R H O S T S DRIVERSDRIVERS 1. AWS - Amazon Web Services 2. Digital Ocean 3. Exoscale 4. Generic ( Fedora, RHEL, CentOS, ... ) 5. GCE - Google Compute Enginer 6. IBM Softlayer 7. Microsoft Azure / Hyper-V 8. OpenStack 9. Oracle VirtualBox 10. Rackspace 11. VMware Fusion / vCloud Air / vSphere USEFUL COMMANDSUSEFUL COMMANDS docker-machine create -d <driver> <name> docker-machine ls docker env <name> ENV VARSENV VARS DOCKER_TLS_VERIFY DOCKER_HOST DOCKER_CERT_PATH DOCKER_MACHINE_NAME
  • 7. Docker commands DOCKER RUNDOCKER RUN Creates a new container docker run <image> command docker run -it <image> command docker run --name -it <image> command docker run --name --rm -it <image> command docker run -d fedora /bin/bash -c "while true; do echo hello world; sleep 1; done"
  • 8. Docker commands OT HE R DOCK ER COMMANDSOT HE R DOCK ER COMMANDS docker ps / docker ps -a docker stop <container> / docker stop -t=1 <container> docker rm <container> / docker rm `docker ps -aq` docker logs <container> / docker logs -f <container> docker attach <container> docker stats <container>
  • 9. 2 Ways to create Docker Images COMMIT WAYCOMMIT WAY docker commit -m "<menssage>" <image name> docker history <image name> DOCKERFILE WAYDOCKERFILE WAY docker build -t <tag> <dockerfile path> DOCKERFILE REFDOCKERFILE REF FROM MAINTAINER WORKDIR ENV RUN COPY ADD EXPOSE VOLUME USER CMD
  • 10. Dockerfile anatomy # Use latest jboss/base-jdk:7 image as the base FROM jboss/base-jdk:8 # Set the WILDFLY_VERSION env variable ENV WILDFLY_VERSION 9.0.0.Final # Add the WildFly distribution to /opt, and make wildfly the owner of the extracted tar content # Make sure the distribution is available from a well-known place RUN cd $HOME && curl http://download.jboss.org/wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.tar.gz | tar zx & # Set the JBOSS_HOME env variable ENV JBOSS_HOME /opt/jboss/wildfly # Expose the ports we're interested in EXPOSE 8080 # Set the default command to run on boot # This will boot WildFly in the standalone mode and bind to all interface CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0"] WildFly Image example
  • 11. Changing container behaviour CHANGING ENV VARCHANGING ENV VAR docker run -e ... EXPOSING PORTSEXPOSING PORTS docker run -P ... docker run -p <host:container> ... docker-machine ip MOUTING VOLUMESMOUTING VOLUMES docker run -v <host:container> ...
  • 12. 3 Ways to deploy an application 1 - MOUNTING A VOLUME1 - MOUNTING A VOLUME docker run -v <host:container> ... 2 - ADMINISTRATIVE CONSOLE2 - ADMINISTRATIVE CONSOLE docker run -p <host:port> ... 3 - INCLUDE INSIDE THE IMAGE3 - INCLUDE INSIDE THE IMAGE Dockerfile ADD your-awesome-app.war /opt/jboss/wildfly/standalone/deployments/
  • 13. Cluster example Apache HTTPD + mod_cluster Postgres database WildFly instances
  • 14. Linking containers [ jboss@22ac4068f95f ~]$ cat /etc/hosts 172.17.0.50 22ac4068f95f 127.0.0.1 localhost 172.17.0.43 db 84e9fc3e4455 172.17.0.44 modcluster 13784a898c33 Environment Variables $DB_NAME $DB_ENV_LANG $DB_ENV_PG_VERSION $DB_ENV_PGDATA $DB_ENV_POSTGRES_PASSWORD $DB_ENV_PG_MAJOR $DB_ENV_POSTGRES_USER $DB_PORT $DB_PORT_5432_TCP $DB_PORT_5432_TCP_PROTO $DB_PORT_5432_TCP_ADDR $DB_PORT_5432_TCP_PORT $MODCLUSTER_NAME $MODCLUSTER_PORT_80_TCP $MODCLUSTER_PORT_80_TCP_PORT $MODCLUSTER_PORT $MODCLUSTER_PORT_80_TCP_ADDR $MODCLUSTER_PORT_80_TCP_PROTO docker run --link <container_name:alias>
  • 15. Docker compose docker-compose.yaml db: image: postgres ports: - "5432:5432" environment: - POSTGRES_USER=ticketmonster - POSTGRES_PASSWORD=ticketmonster-docker modcluster: image: goldmann/mod_cluster ports: - "80:80" wildfly: build: ../Dockerfiles/ticketmonster/ links: - db:db - modcluster:modcluster docker-compose up -d docker-compose ps docker-compose logs docker-compose build docker-compose scale <service>=x
  • 16. DISCLAIMER You're about to see an overview of docker- swarm Some issues found: machine restart cross-host linking
  • 17. Docker Swarm Discovery Services Docker Hub Static file Static list etcd consul zookeeper
  • 18. Creating a Docker Swarm echo "Creating cluster ..." TOKEN=`docker run swarm create` echo "Got the token " $TOKEN echo "Creating Swarm master ..." docker-machine create -d virtualbox --swarm --swarm-master --swarm-strategy=spread --swarm-discovery token://$TOKEN swarm-master echo "Creating Swarm node 01 ..." docker-machine create -d virtualbox --swarm --swarm-discovery token://$TOKEN swarm-node-01 echo "Creating Swarm node 02 ..." docker-machine create -d virtualbox --swarm --swarm-discovery token://$TOKEN swarm-node-02 eval "$(docker-machine env --swarm swarm-master)" Strategy spread* binpack random
  • 21. THANK YOU!THANK YOU! RAFAEL BENEVIDESRAFAEL BENEVIDES [email protected]@REDHAT.COM @RAFABENE@RAFABENE