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: benevides@redhat.com
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/