SlideShare a Scribd company logo
1 of 108
Download to read offline
Using Docker to
build and test in
laptop and
Jenkins
Micael Gallego
micael.gallego@urjc.es
@micael_gallego
@micael_gallego
micael.gallego@urjc.es
@micaelgallego
About me
developer
University professor
Trainer & Consultor
Consultancy / Training
Cloud Computing
WebTechnologies
Extreme Programming
Testing / Git / Jenkins
Software Architecture
Concurrent Programming
Open source elastic platform
for end to end testing
http://codeurjc.es http:/elastest.io
Advanced log management
Test orchestration
Test execution comparison
Web and Mobile testing
Security testing
IoT testing
Performance testing
Virtualizacion and Containers
● Developers want to reduce the
diferencies between local,
continuous integration and
production environments
● It reduce “It works in my machine”
type of problems
Virtualization Containers
Virtualizacion and Containers
● Virtualization
– Full fledged Virtual Machine (VirtualBox)
– Developer friendly managed VM
(Vagrant)
● Containers
– Docker
VirtualBox
● Developed by Oracle (buyed to Sun
Microsystems)
● Open source, several free but closed source
modules
● Windows, Linux and Mac versions
● Advanced Desktop Virtualization
– Shared folders host / guest
– Keyboard and mouse advanced integration
– Graphic 3D acceleration
– Webcam
https://www.virtualbox.org/
VirtualBox
VirtualBox
● Manual
– Create an empty virtual machine
– Connect to a ISO (simulating real CD
devide)
– Install a full fledged Operating System
– It is time consuming and it is not easy
to share VM between developers
VirtualBox
VirtualBox
Vagrant
● It is a command line utility to manage
VMs
● It makes very easy to download and start
a new VM (only with a command)
● Allows to provising the new VM with
command provisioning tools (script, chef,
puppet, ansible…)
● VM configuration is specified in a text file,
allowing to share it in the git repository
https://www.vagrantup.com/
Vagrant
● How to create a new VM with ubuntu Xenial
● Vagrant manages certificates and networking
to make easier to connect to new VM
● By default, local folder is shared
with VM
$ vagrant init ubuntu/xenial64
$ vagrant up
$ vagrant ssh
Docker
● With VM you can have the production
environment in your laptop
● But…
– VMs takes minutes to start up
– VMs use (waste?) a lot of resources
(memory and disk space)
https://www.docker.com/
Docker
● Containers can be considered as
lightweigh VMs
– They contain an isolated environment to run
apps
– Start in milliseconds
– They use only the resources it needs
– A container doesn't have a full fledged
operating system, only the minimal
software to execute apps
Docker
Docker
● Main differences
Virtual Machines Containers
Heavier Lighter
Execute several processes
perVirtual Machine
Usually execute only one
process per container
Ssh connection Direct execution in the
container
More isolated using
hypervisor
Less isolated because are
executed using kernel
features
Docker
● Today, to install an application in a linux
system you need all dependencies
installed
● Docker include in a container all needed
software isolated to the rest of the
system
Docker
Docker
● Docker containers SO support
– Linux
● Very mature technology
● It can be used in any current linux distribution
– Windows
● Preliminary technology
● It only can be used in a very recent Windows
Server version
Docker
● You can execute linux containers in
any operating system
● It uses virtualization under the
covers in Mac and Windows
Docker
● Docker Toolbox for Mac and Windows
– It uses VirtualBox as virtualization
– It is not the same development experience
than linux
● Docker for Mac and Windows
– Newer tools
– Uses native virtualization technology in each
operating system
– Only available in new versions of SOs
Docker
Docker concepts
•Docker Image
– Basic template for a container (hard disk of
VM)
– It contains SO (ubuntu), libs (Java) and app
(webapp.jar)
– A container always is started from an image
– It is easy to download a docker image from
Internet
Docker concepts
•Docker Registry
●
Remote service used to store and retrive docker
images
●
It can hold several versions of the same image
●
All versions of the same image are located in
repositories
●
Docker Hub is a public registry managed by Docker
Inc.
●
You can buy private repositories in Docker Hub
●
You can also operate your own private registry
Docker concepts
•Popular repositories in Docker Hub
Docker concepts
•Docker Container
– It is the equivalent of a virtual machine
– A container is created from a docker image
– When a file is wrote, the image it is not
modified, the container is modified
– It can be started, paused or
stopped
Docker concepts
•Docker Engine
– Local service used to control docker
– Manages images (download, create, pull,
push…)
– Manages containers (start, stop, commit...)
– It can be used with the docker client or
using its REST API
Docker concepts
•Docker client
– Command line interface (CLI) tool to
control docker engine
– It is available when docker is installed in a
system to connect to their local docker
engine
Docker concepts
•Official documentation
– https://docs.docker.com/
•Advanced tutorials
– https://docs.docker.com/engine/tutorials/dockerizing/
– https://docs.docker.com/engine/tutorials/usingdocker/
– https://docs.docker.com/engine/tutorials/dockerimages/
– https://docs.docker.com/engine/tutorials/networkingcontainers/
– https://docs.docker.com/engine/tutorials/dockervolumes/
– https://docs.docker.com/engine/tutorials/dockerrepos/
●
Cheat Sheet
– https://github.com/wsargent/docker-cheat-sheet/blob/master/README.md
Docker documentation
First steps with docker
– Official beginners tutorial
– Install docker
https://store.docker.com/search?type=edition&offering=community
https://github.com/docker/labs/tree/master/beginner
First steps with docker
Hands on…
First steps with docker
Testing if docker is correctly installed
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
03f4658f8b78: Pull complete
a3ed95caeb02: Pull complete
Digest:
sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca369
66a7
Status: Downloaded newer image for hello-world:latest
Hello from Docker.
This message shows that your installation appears to be working
correctly.
...
First steps with docker
Running your first container
$ docker run alpine ls -l
total 48
drwxr-xr-x 2 root root 4096 Mar 2 16:20 bin
drwxr-xr-x 5 root root 360 Mar 18 09:47 dev
drwxr-xr-x 13 root root 4096 Mar 18 09:47 etc
drwxr-xr-x 2 root root 4096 Mar 2 16:20
home
drwxr-xr-x 5 root root 4096 Mar 2 16:20 lib
......
......
First steps with docker
Running your first container
$ docker run alpine ls -l
Command “run”
Creates a new
container and start it
First steps with docker
Running your first container
$ docker run alpine ls -l
Image name
alpine is a minimal linux system
(4.8Mb).The image is downloaded if
not stored in local machine
First steps with docker
Running your first container
$ docker run alpine ls -l
Command “ls -l”
This command will be
executed inside the
running container
First steps with docker
Inspecting the downloaded images
$ docker images
REPOSITORY TAG IMAGE ID
CREATED VIRTUAL SIZE
alpine latest c51f86c28340
4 weeks ago 1.109 MB
hello-world latest 690ed74de00f
5 months ago 960 B
List all images stored in the system
First steps with docker
Executing a container
$ docker run alpine echo "hello from alpine"
hello from alpine
Execute the command “echo” inside the container
First steps with docker
Inspecting containers (executing)
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED
STATUS PORTS NAMES
a6a9d46d0b2f alpine "echo 'hello from alp" 6 minutes
ago Exited (0) 6 minutes ago lonely_kilby
ff0a5c3750b9 alpine "ls -l" 8 minutes
ago Exited (0) 8 minutes ago elated_ramanujan
c317d0a9e3d2 hello-world "/hello" 34 seconds
ago Exited (0) 12 minutes ago stupefied_mcclintock
It shows containers in the system.
All of them has STATUS Existed.These containers are
not currently executing
First steps with docker
Interactive commands in containers
$ docker run -it alpine /bin/sh
/ # ls
bin dev etc home lib linuxrc media mnt proc
root run sbin sys tmp usr var
/ # uname -a
Linux 97916e8cb5dc 4.4.27-moby #1 SMP Wed Oct 26 14:01:48 UTC 2016 x86_64
Linux
/ # exit
$
To execute an interactive command it is necessary to
use the option “-it” to connect the console to the
container command
First steps with docker
● Interactive commands in containers
– When you execute a /bin/sh command in
a container it is similar to an ssh
connection
– There are no ssh server neither ssh client
– It is executing a shell inside the
container
First steps with docker
● Managing containers lifecycle
$ docker run -d seqvence/static-site
Option “-d”
Executes the container
in background
First steps with docker
● Managing containers lifecycle
$ docker ps
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS NAMES
a7a0e504ca3e seqvence/static-site "/bin/sh -c 'cd /usr/"
28 seconds ago Up 26 seconds
Container id is
a7a0e504ca3e
This id is used to refer to
this container
STATUS is UP
First steps with docker
● Managing containers lifecycle
– Stop running container
– Delete files of the stopped container
$ docker stop a7a0e504ca3e
$ docker rm a7a0e504ca3e
Net services with docker
● Start container exposing a port
docker run --name static-site 
-e AUTHOR="Your Name" -d 
-p 9000:80 seqvence/static-site
Net services with docker
● Start container exposing a port
docker run --name static-site 
-e AUTHOR="Your Name" -d 
-p 9000:80 seqvence/static-site
--name static-site
Specifies a unique name
for the container
Net services with docker
docker run --name static-site 
-e AUTHOR="Your Name" -d 
-p 9000:80 seqvence/static-site
-e AUTHOR="Your Name"
Set the environment variable
AUTHOR to value “Your Name”
● Start container exposing a port
Net services with docker
docker run --name static-site 
-e AUTHOR="Your Name" -d 
-p 9000:80 seqvence/static-site
-d
Execute container as deamon
● Start container exposing a port
Net services with docker
docker run --name static-site 
-e AUTHOR="Your Name" -d 
-p 9000:80 seqvence/static-site
-p 9000:80
Connects the host port 9000 to
the port 80 in the container
● Start container exposing a port
Net services with docker
● Use the service
– Open http://127.0.0.1:9000 in a browser in
your host to access 80 port in container
Net services with docker
● Use the service
– If you are using Docker Toolbox for Mac or
Windows
– Then you have to open
http://192.168.99.100:9000/ in the browser
$ docker-machine ip default
192.168.99.100
Net services with docker
● Container management
– Stop and remove the container
– Stop and remove a running container
– Remove all running containers
$ docker rm -f static-site
$ docker stop static-site
$ docker rm static-site
$ docker rm -f $(docker ps -a -q)
Managing docker images
● List images in host
Tag is like “version”. Latest is… the
latest ;)
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
seqvence/static-site latest 92a386b6e686 2 hours ago 190.5 MB
nginx latest af4b3d7d5401 3 hours ago 190.5 MB
python 2.7 1c32174fd534 14 hours ago 676.8 MB
postgres 9.4 88d845ac7a88 14 hours ago 263.6 MB
Containous/traefik latest 27b4e0c6b2fd 4 days ago 20.75 MB
...
Managing docker images
● Managing versions
– Download a concrete version
– Download latest version
$ docker pull ubuntu:12.04
$ docker pull ubuntu
Managing docker images
● Searching images in DockerHub
Managing docker images
● Searching images in Docker Store
Managing docker images
● Image types
– Base images
● Images without a parent image
● Examples: Ubuntu, debian, alpine…
– Child images
● Base images plus some additional
software
● Examples: Nginx, Apache, MySQL...
Managing docker images
● Official vs User images
– Official images
● Images created by trusted
companies or communities
– User images
● Any user can create an account and
upload her own images
Managing docker images
● Create your first image
– We will create a web application for display
random cat pics using Python
– Create a folder called flask-app
– Download all files in this URL to the folder
https://github.com/docker/labs/tree/master/beginner/flask-app
Managing docker images
● Create your first image
– You have all source files for the web
application
– But you need Python and Flask to execute
the app
– To execute the web application, you will
create a new image with dependencies
(Python and Flask) and your application code
– Then you can create a new container to
execute your application
Managing docker images
● Dockerfile
– File used to describe a new image
– Specifies
● Base image
● Commands to execute in the image
● Files to include in the image from the
project folder
● Open ports
● Command to execute when start the image
# Select base image
FROM alpine:latest
# Install python and pip
RUN apk add ­­update py­pip
RUN pip install ­­upgrade pip
# copy app files
COPY app.py /usr/src/app/
COPY templates/index.html /usr/src/app/templates/
COPY requirements.txt /usr/src/app/
# install Python modules needed by the app
RUN pip install ­­no­cache­dir ­r  
   /usr/src/app/requirements.txt
# tell the port number the container should expose
EXPOSE 5000
# run the application
CMD ["python", "/usr/src/app/app.py"]
Managing docker images
● Dockerfile
– FROM: Base image
– COPY: Copy files from Dockerfile folder
– RUN execute commands
– EXPOSE: Public ports
– CMD: Command to execute when
container is started
https://docs.docker.com/engine/userguide/eng-
image/dockerfile_best-practices/
Managing docker images
● Build the image
– In the folder with a Dockerfile execute
– Executed actions
● Create a new container with base image
● Execute commands and copy app files
● Create a new container with the result
$ docker build -t myfirstimage .
Managing docker images
● Run the new image
– Open http://127.0.0.1:9000/ in the browser
– Windows and Mac users with Toolbox use the IP
$ docker run -p 9000:5000 myfirstimage
* Running on http://0.0.0.0:5000/
(Press CTRL+C to quit)
Managing docker images
● Build the image again
– Change some HTML in templatesindex.html
– Create the image again
– The steps that doesn't change are not executed
again
– The image is created very quickly because only
the files copy is perfomed
$ docker build -t myfirstimage .
Volumes
● Volumes
– Allow sharing files between host and container
– Execute a container to show an nonexistent file
– Create a text file
$ docker run alpine cat /data/file.txt
cat: can't open '/data/file.txt': No such
file or directory
$ echo "My file" >> file.txt
Volumes
Volumes
● Mount a host folder inside a container folder
● Host contents replace container contents of
that folder
● Containers can write files in volumes to be
available in the host
$ sudo docker run -v $PWD:/data alpine
cat /data/file.txt
My file
Volumes
● Volumes
– Docker images use volumes to read files
from host
– Official NGINX container can serve host
files using http
● Serving current folder files ($PWD)
● Go to http://127.0.0.1:9000/file.txt
https://hub.docker.com/_/nginx/
$ docker run -p 9000:80 -v 
$PWD:/usr/share/nginx/html:ro -d nginx
Volumes
● Volumes
– Docker Toolbox for Win or
Mac only allow folders
inside user folder to be
used as volume
– You can use other folders
but have to configure
shared folders in
VirtualBox
https://hub.docker.com/_/nginx/
•Containers main use cases
– Net service
●
Executed in background long time...
●
Used through network
●
Ex: Databases, web servers...
– Command
●
Execute a single command and stop
●
Read and write files from host with volumes
●
Ex: Java Compiler, jekyll, ffmpeg...
Docker container usage
•Docker for building software
– A container can have all needed environment to
execute a developer tool
– For example, you can have the compiler and the
test dependencies in a container
– You can clone a git repository and execute the
(dockerized) compiler without install any
software in your host
Docker for software developers
•Dockerized Java Maven
– Clone a maven repo
– Compile and exec tests
Docker for software developers
$ git clone 
https://github.com/jglick/simple-maven-project-with-tests.git
$ cd simple-maven-project-with-tests
$ docker run --rm -v $PWD:/data -w /data maven mvn package
•Dockerized Java Maven
Docker for software developers
$ docker run --rm -v $PWD:/data -w /data maven mvn package
https://hub.docker.com/_/maven/
--rm
Remove container when
execution finish
•Dockerized Java Maven
Docker for software developers
$ docker run --rm -v $PWD:/data -w /data maven mvn package
https://hub.docker.com/_/maven/
--w
Working dir for the command
•Dockerized Java Maven
Docker for software developers
$ docker run --rm -v $PWD:/data -w /data maven mvn package
https://hub.docker.com/_/maven/
maven
Official Maven image
•Dockerized Java Maven
Docker for software developers
$ docker run --rm -v $PWD:/data -w /data maven mvn package
https://hub.docker.com/_/maven/
mvn package
Maven command
•Dockerized Java Maven
– Jar package is generated in /target folder in host
– As container is executed with root user,
generated files are owned by root.
– Change to your user
Docker for software developers
simple-maven-project-with-tests-1.0-SNAPSHOT.jar
https://hub.docker.com/_/maven/
sudo chown -R username:group target
•Advantages of dockerized dev tools
– Avoid several developers having different
versions of such tools
– It is very easy to test the same code in different
versions (Java 7, Java 8...)
– Reduce tools configuration problems.You can
compile and execute a project easily
– The same tools can be executed in development
laptops and also in CI environment
Docker for software developers
Docker for software developers
•Docker in Continuous Integration
– If you execute dev tools in containers, it is very
easy to compile, test and package in CI
environment
– Only have to execute the same command in
laptop and CI environment
– If a tool changes, only have to change the
command, it is not necessary to install anything
Docker in CI servers
https://jenkins.io/
•Docker in Continuous Integration
Docker in CI servers
● Jenkins installation
– You need Java
– Go to https://jenkins.io/
– Download LTS Release
Docker in CI servers
Jenkins installation
Jenkins installation
New admin
account
Jenkins installation
Jenkins installation
● Create new Jenkins job
– Create a job with pipeline
– Pipeline:
● Clone git repository
● Compile, test and package Java project
● Copy test results to Jenkins
Jenkins Job
Creamos una nueva
tarea para descargar el
proyecto y ejecutar los
tests
Jenkins Job
Jenkins Job
Change command
to execute
dockerized maven
command
node {
// Mark the code checkout 'stage'....
stage 'Checkout'
// Get some code from a GitHub repository
git url: 'https://github.com/jglick/simple-maven-project-with-tests.git'
// Mark the code build 'stage'....
stage 'Build'
// Run the maven build
sh "docker run --rm -v $PWD:/data -w /data maven mvn package"
step([$class: 'JUnitResultArchiver',
testResults: '**/target/surefire-reports/TEST-*.xml'])
}
Pipeline
Jenkins Job
Execute the
new job
Jenkins Job
“Checkout”
stage
Jenkins Job
Compilation and
test stage
Jenkins Job
Successful finished job
build (test passed)
Jenkins Job
Clic on build to see
details
Jenkins Job
See console output
Jenkins Job
Repository clone
and dockerized
maven execution
Jenkins Job
● Advantages of using docker in CI
– CI server just need docker installed, nothing
more
– All tools needed by devs are containerized
– Tools are downloaded (and cached)
automatically when needed
– Several languages/stacks/dependencies can be
used in the same CI server without conflicts
– Sysadmins do not need to give access to CI
server to developers (enforcing security)
Docker in CI servers
● Some issues of using docker in CI
– Issue: By default project dependencies have to
be downloaded in every build
● Solution: Use a host folder as cache
– Issue: Old docker images waste HD space
● Solution: Use docker garbage collector (as you
can download images when needed)
– Issue: Window tools can’t be dockerized in linux
containers
● Solution: Use portable tools as much as
possible ;)
Docker in CI servers
● Docker plugins for Jenkins
– Docker Plugin
● https://wiki.jenkins-ci.org/display/JENKINS/Docker+Plugin
– Docker build step plugin
● https://wiki.jenkins-ci.org/display/JENKINS/Docker+build+step+plugin
– CloudBees Docker Custom Build Environment Plugin
● https://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Docker+Custom+Buil
d+Environment+Plugin
– Docker Slaves Plugin
● https://wiki.jenkins-ci.org/display/JENKINS/Docker+Slaves+Plugin
– Yet Another Docker Plugin:
● https://wiki.jenkins-ci.org/display/JENKINS/Yet+Another+Docker+Plugin
Docker in CI servers
● Conclusions
– Docker containers are changing the way we
develop, build, test and ship software
– Containers allow developers to use the same dev
tools and execute the project in the same
environment
– Containers ease the configuration and share of CI
servers
– If Continuous Integration is easier to use, more
projects will use it and more test will be executed
Docker in CI servers
Thanks!
Do you have any
question?

More Related Content

What's hot

Docker and the Linux Kernel
Docker and the Linux KernelDocker and the Linux Kernel
Docker and the Linux KernelDocker, Inc.
 
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @GuidewireIntroduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @GuidewiredotCloud
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basicsWalid Ashraf
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to DockerAlan Forbes
 
Shipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerShipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerJérôme Petazzoni
 
Docker 101 - Intro to Docker
Docker 101 - Intro to DockerDocker 101 - Intro to Docker
Docker 101 - Intro to DockerAdrian Otto
 
Containerization and Docker
Containerization and DockerContainerization and Docker
Containerization and DockerMegha Bansal
 
Vagrant and docker
Vagrant and dockerVagrant and docker
Vagrant and dockerDuckDuckGo
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker IntroductionSparkbit
 
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
 
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
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshopRuncy Oommen
 
Docker based-pipelines
Docker based-pipelinesDocker based-pipelines
Docker based-pipelinesDevOps.com
 

What's hot (20)

JOSA TechTalk: Taking Docker to Production
JOSA TechTalk: Taking Docker to ProductionJOSA TechTalk: Taking Docker to Production
JOSA TechTalk: Taking Docker to Production
 
Docker and the Linux Kernel
Docker and the Linux KernelDocker and the Linux Kernel
Docker and the Linux Kernel
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @GuidewireIntroduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basics
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Shipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with DockerShipping Applications to Production in Containers with Docker
Shipping Applications to Production in Containers with Docker
 
Learning Docker with Thomas
Learning Docker with ThomasLearning Docker with Thomas
Learning Docker with Thomas
 
Docker 101 - Intro to Docker
Docker 101 - Intro to DockerDocker 101 - Intro to Docker
Docker 101 - Intro to Docker
 
Containerization and Docker
Containerization and DockerContainerization and Docker
Containerization and Docker
 
Vagrant and docker
Vagrant and dockerVagrant and docker
Vagrant and docker
 
Docker in real life
Docker in real lifeDocker in real life
Docker in real life
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Introduction To Docker
Introduction To  DockerIntroduction To  Docker
Introduction To Docker
 
Docker
DockerDocker
Docker
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
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
 
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
 
Docker Introductory workshop
Docker Introductory workshopDocker Introductory workshop
Docker Introductory workshop
 
Docker based-pipelines
Docker based-pipelinesDocker based-pipelines
Docker based-pipelines
 

Similar to ExpoQA 2017 Using docker to build and test in your laptop and Jenkins

Using Docker to build and test in your laptop and Jenkins
Using Docker to build and test in your laptop and JenkinsUsing Docker to build and test in your laptop and Jenkins
Using Docker to build and test in your laptop and JenkinsMicael Gallego
 
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
 
Docker for .NET Developers
Docker for .NET DevelopersDocker for .NET Developers
Docker for .NET DevelopersTaswar Bhatti
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with DockerGeeta Vinnakota
 
Tech talk on docker with demo
Tech talk on docker with demoTech talk on docker with demo
Tech talk on docker with demoSandeep Karnawat
 
Using Docker with OpenStack - Hands On!
 Using Docker with OpenStack - Hands On! Using Docker with OpenStack - Hands On!
Using Docker with OpenStack - Hands On!Adrian Otto
 
Docker - The Linux Container
Docker - The Linux ContainerDocker - The Linux Container
Docker - The Linux ContainerBalaji Rajan
 
Testing fácil con Docker: Gestiona dependencias y unifica entornos
Testing fácil con Docker: Gestiona dependencias y unifica entornosTesting fácil con Docker: Gestiona dependencias y unifica entornos
Testing fácil con Docker: Gestiona dependencias y unifica entornosMicael Gallego
 
Introduction to Docker Containers - Docker Captain
Introduction to Docker Containers - Docker CaptainIntroduction to Docker Containers - Docker Captain
Introduction to Docker Containers - Docker CaptainAjeet Singh Raina
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014Carlo Bonamico
 
Introduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataIntroduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataInfluxData
 
Virtual Machines and Docker
Virtual Machines and DockerVirtual Machines and Docker
Virtual Machines and DockerDanish Khakwani
 
Michigan IT Symposium 2017 - Container BOF
Michigan IT Symposium 2017 - Container BOFMichigan IT Symposium 2017 - Container BOF
Michigan IT Symposium 2017 - Container BOFJeffrey Sica
 

Similar to ExpoQA 2017 Using docker to build and test in your laptop and Jenkins (20)

Using Docker to build and test in your laptop and Jenkins
Using Docker to build and test in your laptop and JenkinsUsing Docker to build and test in your laptop and Jenkins
Using Docker to build and test in your laptop and Jenkins
 
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
 
Docker for .NET Developers
Docker for .NET DevelopersDocker for .NET Developers
Docker for .NET Developers
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with Docker
 
Tech talk on docker with demo
Tech talk on docker with demoTech talk on docker with demo
Tech talk on docker with demo
 
Using Docker with OpenStack - Hands On!
 Using Docker with OpenStack - Hands On! Using Docker with OpenStack - Hands On!
Using Docker with OpenStack - Hands On!
 
Docker 2014
Docker 2014Docker 2014
Docker 2014
 
Docker Ecosystem on Azure
Docker Ecosystem on AzureDocker Ecosystem on Azure
Docker Ecosystem on Azure
 
Docker+java
Docker+javaDocker+java
Docker+java
 
Docker - The Linux Container
Docker - The Linux ContainerDocker - The Linux Container
Docker - The Linux Container
 
Testing fácil con Docker: Gestiona dependencias y unifica entornos
Testing fácil con Docker: Gestiona dependencias y unifica entornosTesting fácil con Docker: Gestiona dependencias y unifica entornos
Testing fácil con Docker: Gestiona dependencias y unifica entornos
 
Introduction to Docker Containers - Docker Captain
Introduction to Docker Containers - Docker CaptainIntroduction to Docker Containers - Docker Captain
Introduction to Docker Containers - Docker Captain
 
Docker
DockerDocker
Docker
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014
 
Introduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxDataIntroduction to Docker and Monitoring with InfluxData
Introduction to Docker and Monitoring with InfluxData
 
Docker presentation
Docker presentationDocker presentation
Docker presentation
 
Virtual Machines and Docker
Virtual Machines and DockerVirtual Machines and Docker
Virtual Machines and Docker
 
Docker quick start
Docker quick startDocker quick start
Docker quick start
 
Michigan IT Symposium 2017 - Container BOF
Michigan IT Symposium 2017 - Container BOFMichigan IT Symposium 2017 - Container BOF
Michigan IT Symposium 2017 - Container BOF
 

More from ElasTest Project

ElasTest: quality for cloud native applications
ElasTest: quality for cloud native applicationsElasTest: quality for cloud native applications
ElasTest: quality for cloud native applicationsElasTest Project
 
How to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipelineHow to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipelineElasTest Project
 
Bringing observability to your testing environments
Bringing observability to your testing environmentsBringing observability to your testing environments
Bringing observability to your testing environmentsElasTest Project
 
Life-cycle is too short not to use ElasTest
Life-cycle is too short not to use ElasTestLife-cycle is too short not to use ElasTest
Life-cycle is too short not to use ElasTestElasTest Project
 
ElasTest presentation in MadridJUG (Madrid December 2017)
ElasTest presentation in MadridJUG (Madrid December 2017)ElasTest presentation in MadridJUG (Madrid December 2017)
ElasTest presentation in MadridJUG (Madrid December 2017)ElasTest Project
 
ElasTest presentation in Panel Sistemas company (Madrid December 2017)
ElasTest presentation in Panel Sistemas company (Madrid December 2017)ElasTest presentation in Panel Sistemas company (Madrid December 2017)
ElasTest presentation in Panel Sistemas company (Madrid December 2017)ElasTest Project
 
ElasTest presentation in VLCTesting Conference (Valencia Novemeber 2017)
ElasTest presentation in VLCTesting Conference (Valencia Novemeber 2017)ElasTest presentation in VLCTesting Conference (Valencia Novemeber 2017)
ElasTest presentation in VLCTesting Conference (Valencia Novemeber 2017)ElasTest Project
 
ElasTest - Testing in the large
ElasTest - Testing in the largeElasTest - Testing in the large
ElasTest - Testing in the largeElasTest Project
 
ElasTest ICSOFT 2017 - Panel H2020
ElasTest ICSOFT 2017 - Panel H2020ElasTest ICSOFT 2017 - Panel H2020
ElasTest ICSOFT 2017 - Panel H2020ElasTest Project
 
ElasTest technical presentation
ElasTest technical presentationElasTest technical presentation
ElasTest technical presentationElasTest Project
 

More from ElasTest Project (13)

ElasTest: quality for cloud native applications
ElasTest: quality for cloud native applicationsElasTest: quality for cloud native applications
ElasTest: quality for cloud native applications
 
How to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipelineHow to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipeline
 
Bringing observability to your testing environments
Bringing observability to your testing environmentsBringing observability to your testing environments
Bringing observability to your testing environments
 
Life-cycle is too short not to use ElasTest
Life-cycle is too short not to use ElasTestLife-cycle is too short not to use ElasTest
Life-cycle is too short not to use ElasTest
 
ElasTest Webinar
ElasTest WebinarElasTest Webinar
ElasTest Webinar
 
ElasTest presentation in MadridJUG (Madrid December 2017)
ElasTest presentation in MadridJUG (Madrid December 2017)ElasTest presentation in MadridJUG (Madrid December 2017)
ElasTest presentation in MadridJUG (Madrid December 2017)
 
ElasTest presentation in Panel Sistemas company (Madrid December 2017)
ElasTest presentation in Panel Sistemas company (Madrid December 2017)ElasTest presentation in Panel Sistemas company (Madrid December 2017)
ElasTest presentation in Panel Sistemas company (Madrid December 2017)
 
ElasTest presentation in VLCTesting Conference (Valencia Novemeber 2017)
ElasTest presentation in VLCTesting Conference (Valencia Novemeber 2017)ElasTest presentation in VLCTesting Conference (Valencia Novemeber 2017)
ElasTest presentation in VLCTesting Conference (Valencia Novemeber 2017)
 
ElasTest - Testing in the large
ElasTest - Testing in the largeElasTest - Testing in the large
ElasTest - Testing in the large
 
ElasTest ICSOFT 2017 - Panel H2020
ElasTest ICSOFT 2017 - Panel H2020ElasTest ICSOFT 2017 - Panel H2020
ElasTest ICSOFT 2017 - Panel H2020
 
ExpoQA 2017 Docker and CI
ExpoQA 2017 Docker and CIExpoQA 2017 Docker and CI
ExpoQA 2017 Docker and CI
 
Tarot 2017
Tarot 2017Tarot 2017
Tarot 2017
 
ElasTest technical presentation
ElasTest technical presentationElasTest technical presentation
ElasTest technical presentation
 

Recently uploaded

Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 

Recently uploaded (20)

Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 

ExpoQA 2017 Using docker to build and test in your laptop and Jenkins

  • 1.
  • 2. Using Docker to build and test in laptop and Jenkins Micael Gallego micael.gallego@urjc.es @micael_gallego
  • 4. Consultancy / Training Cloud Computing WebTechnologies Extreme Programming Testing / Git / Jenkins Software Architecture Concurrent Programming Open source elastic platform for end to end testing http://codeurjc.es http:/elastest.io Advanced log management Test orchestration Test execution comparison Web and Mobile testing Security testing IoT testing Performance testing
  • 5. Virtualizacion and Containers ● Developers want to reduce the diferencies between local, continuous integration and production environments ● It reduce “It works in my machine” type of problems Virtualization Containers
  • 6. Virtualizacion and Containers ● Virtualization – Full fledged Virtual Machine (VirtualBox) – Developer friendly managed VM (Vagrant) ● Containers – Docker
  • 7.
  • 8. VirtualBox ● Developed by Oracle (buyed to Sun Microsystems) ● Open source, several free but closed source modules ● Windows, Linux and Mac versions ● Advanced Desktop Virtualization – Shared folders host / guest – Keyboard and mouse advanced integration – Graphic 3D acceleration – Webcam https://www.virtualbox.org/
  • 10. VirtualBox ● Manual – Create an empty virtual machine – Connect to a ISO (simulating real CD devide) – Install a full fledged Operating System – It is time consuming and it is not easy to share VM between developers
  • 13.
  • 14. Vagrant ● It is a command line utility to manage VMs ● It makes very easy to download and start a new VM (only with a command) ● Allows to provising the new VM with command provisioning tools (script, chef, puppet, ansible…) ● VM configuration is specified in a text file, allowing to share it in the git repository https://www.vagrantup.com/
  • 15. Vagrant ● How to create a new VM with ubuntu Xenial ● Vagrant manages certificates and networking to make easier to connect to new VM ● By default, local folder is shared with VM $ vagrant init ubuntu/xenial64 $ vagrant up $ vagrant ssh
  • 16.
  • 17. Docker ● With VM you can have the production environment in your laptop ● But… – VMs takes minutes to start up – VMs use (waste?) a lot of resources (memory and disk space) https://www.docker.com/
  • 18. Docker ● Containers can be considered as lightweigh VMs – They contain an isolated environment to run apps – Start in milliseconds – They use only the resources it needs – A container doesn't have a full fledged operating system, only the minimal software to execute apps
  • 20. Docker ● Main differences Virtual Machines Containers Heavier Lighter Execute several processes perVirtual Machine Usually execute only one process per container Ssh connection Direct execution in the container More isolated using hypervisor Less isolated because are executed using kernel features
  • 21. Docker ● Today, to install an application in a linux system you need all dependencies installed ● Docker include in a container all needed software isolated to the rest of the system
  • 23. Docker ● Docker containers SO support – Linux ● Very mature technology ● It can be used in any current linux distribution – Windows ● Preliminary technology ● It only can be used in a very recent Windows Server version
  • 24. Docker ● You can execute linux containers in any operating system ● It uses virtualization under the covers in Mac and Windows
  • 25. Docker ● Docker Toolbox for Mac and Windows – It uses VirtualBox as virtualization – It is not the same development experience than linux ● Docker for Mac and Windows – Newer tools – Uses native virtualization technology in each operating system – Only available in new versions of SOs
  • 27. •Docker Image – Basic template for a container (hard disk of VM) – It contains SO (ubuntu), libs (Java) and app (webapp.jar) – A container always is started from an image – It is easy to download a docker image from Internet Docker concepts
  • 28. •Docker Registry ● Remote service used to store and retrive docker images ● It can hold several versions of the same image ● All versions of the same image are located in repositories ● Docker Hub is a public registry managed by Docker Inc. ● You can buy private repositories in Docker Hub ● You can also operate your own private registry Docker concepts
  • 29. •Popular repositories in Docker Hub Docker concepts
  • 30. •Docker Container – It is the equivalent of a virtual machine – A container is created from a docker image – When a file is wrote, the image it is not modified, the container is modified – It can be started, paused or stopped Docker concepts
  • 31. •Docker Engine – Local service used to control docker – Manages images (download, create, pull, push…) – Manages containers (start, stop, commit...) – It can be used with the docker client or using its REST API Docker concepts
  • 32. •Docker client – Command line interface (CLI) tool to control docker engine – It is available when docker is installed in a system to connect to their local docker engine Docker concepts
  • 33. •Official documentation – https://docs.docker.com/ •Advanced tutorials – https://docs.docker.com/engine/tutorials/dockerizing/ – https://docs.docker.com/engine/tutorials/usingdocker/ – https://docs.docker.com/engine/tutorials/dockerimages/ – https://docs.docker.com/engine/tutorials/networkingcontainers/ – https://docs.docker.com/engine/tutorials/dockervolumes/ – https://docs.docker.com/engine/tutorials/dockerrepos/ ● Cheat Sheet – https://github.com/wsargent/docker-cheat-sheet/blob/master/README.md Docker documentation
  • 34. First steps with docker – Official beginners tutorial – Install docker https://store.docker.com/search?type=edition&offering=community https://github.com/docker/labs/tree/master/beginner
  • 35. First steps with docker Hands on…
  • 36. First steps with docker Testing if docker is correctly installed $ docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 03f4658f8b78: Pull complete a3ed95caeb02: Pull complete Digest: sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca369 66a7 Status: Downloaded newer image for hello-world:latest Hello from Docker. This message shows that your installation appears to be working correctly. ...
  • 37. First steps with docker Running your first container $ docker run alpine ls -l total 48 drwxr-xr-x 2 root root 4096 Mar 2 16:20 bin drwxr-xr-x 5 root root 360 Mar 18 09:47 dev drwxr-xr-x 13 root root 4096 Mar 18 09:47 etc drwxr-xr-x 2 root root 4096 Mar 2 16:20 home drwxr-xr-x 5 root root 4096 Mar 2 16:20 lib ...... ......
  • 38. First steps with docker Running your first container $ docker run alpine ls -l Command “run” Creates a new container and start it
  • 39. First steps with docker Running your first container $ docker run alpine ls -l Image name alpine is a minimal linux system (4.8Mb).The image is downloaded if not stored in local machine
  • 40. First steps with docker Running your first container $ docker run alpine ls -l Command “ls -l” This command will be executed inside the running container
  • 41. First steps with docker Inspecting the downloaded images $ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE alpine latest c51f86c28340 4 weeks ago 1.109 MB hello-world latest 690ed74de00f 5 months ago 960 B List all images stored in the system
  • 42. First steps with docker Executing a container $ docker run alpine echo "hello from alpine" hello from alpine Execute the command “echo” inside the container
  • 43. First steps with docker Inspecting containers (executing) $ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a6a9d46d0b2f alpine "echo 'hello from alp" 6 minutes ago Exited (0) 6 minutes ago lonely_kilby ff0a5c3750b9 alpine "ls -l" 8 minutes ago Exited (0) 8 minutes ago elated_ramanujan c317d0a9e3d2 hello-world "/hello" 34 seconds ago Exited (0) 12 minutes ago stupefied_mcclintock It shows containers in the system. All of them has STATUS Existed.These containers are not currently executing
  • 44. First steps with docker Interactive commands in containers $ docker run -it alpine /bin/sh / # ls bin dev etc home lib linuxrc media mnt proc root run sbin sys tmp usr var / # uname -a Linux 97916e8cb5dc 4.4.27-moby #1 SMP Wed Oct 26 14:01:48 UTC 2016 x86_64 Linux / # exit $ To execute an interactive command it is necessary to use the option “-it” to connect the console to the container command
  • 45. First steps with docker ● Interactive commands in containers – When you execute a /bin/sh command in a container it is similar to an ssh connection – There are no ssh server neither ssh client – It is executing a shell inside the container
  • 46. First steps with docker ● Managing containers lifecycle $ docker run -d seqvence/static-site Option “-d” Executes the container in background
  • 47. First steps with docker ● Managing containers lifecycle $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a7a0e504ca3e seqvence/static-site "/bin/sh -c 'cd /usr/" 28 seconds ago Up 26 seconds Container id is a7a0e504ca3e This id is used to refer to this container STATUS is UP
  • 48. First steps with docker ● Managing containers lifecycle – Stop running container – Delete files of the stopped container $ docker stop a7a0e504ca3e $ docker rm a7a0e504ca3e
  • 49. Net services with docker ● Start container exposing a port docker run --name static-site -e AUTHOR="Your Name" -d -p 9000:80 seqvence/static-site
  • 50. Net services with docker ● Start container exposing a port docker run --name static-site -e AUTHOR="Your Name" -d -p 9000:80 seqvence/static-site --name static-site Specifies a unique name for the container
  • 51. Net services with docker docker run --name static-site -e AUTHOR="Your Name" -d -p 9000:80 seqvence/static-site -e AUTHOR="Your Name" Set the environment variable AUTHOR to value “Your Name” ● Start container exposing a port
  • 52. Net services with docker docker run --name static-site -e AUTHOR="Your Name" -d -p 9000:80 seqvence/static-site -d Execute container as deamon ● Start container exposing a port
  • 53. Net services with docker docker run --name static-site -e AUTHOR="Your Name" -d -p 9000:80 seqvence/static-site -p 9000:80 Connects the host port 9000 to the port 80 in the container ● Start container exposing a port
  • 54. Net services with docker ● Use the service – Open http://127.0.0.1:9000 in a browser in your host to access 80 port in container
  • 55. Net services with docker ● Use the service – If you are using Docker Toolbox for Mac or Windows – Then you have to open http://192.168.99.100:9000/ in the browser $ docker-machine ip default 192.168.99.100
  • 56. Net services with docker ● Container management – Stop and remove the container – Stop and remove a running container – Remove all running containers $ docker rm -f static-site $ docker stop static-site $ docker rm static-site $ docker rm -f $(docker ps -a -q)
  • 57. Managing docker images ● List images in host Tag is like “version”. Latest is… the latest ;) $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE seqvence/static-site latest 92a386b6e686 2 hours ago 190.5 MB nginx latest af4b3d7d5401 3 hours ago 190.5 MB python 2.7 1c32174fd534 14 hours ago 676.8 MB postgres 9.4 88d845ac7a88 14 hours ago 263.6 MB Containous/traefik latest 27b4e0c6b2fd 4 days ago 20.75 MB ...
  • 58. Managing docker images ● Managing versions – Download a concrete version – Download latest version $ docker pull ubuntu:12.04 $ docker pull ubuntu
  • 59. Managing docker images ● Searching images in DockerHub
  • 60. Managing docker images ● Searching images in Docker Store
  • 61. Managing docker images ● Image types – Base images ● Images without a parent image ● Examples: Ubuntu, debian, alpine… – Child images ● Base images plus some additional software ● Examples: Nginx, Apache, MySQL...
  • 62. Managing docker images ● Official vs User images – Official images ● Images created by trusted companies or communities – User images ● Any user can create an account and upload her own images
  • 63. Managing docker images ● Create your first image – We will create a web application for display random cat pics using Python – Create a folder called flask-app – Download all files in this URL to the folder https://github.com/docker/labs/tree/master/beginner/flask-app
  • 64. Managing docker images ● Create your first image – You have all source files for the web application – But you need Python and Flask to execute the app – To execute the web application, you will create a new image with dependencies (Python and Flask) and your application code – Then you can create a new container to execute your application
  • 65. Managing docker images ● Dockerfile – File used to describe a new image – Specifies ● Base image ● Commands to execute in the image ● Files to include in the image from the project folder ● Open ports ● Command to execute when start the image
  • 67. Managing docker images ● Dockerfile – FROM: Base image – COPY: Copy files from Dockerfile folder – RUN execute commands – EXPOSE: Public ports – CMD: Command to execute when container is started https://docs.docker.com/engine/userguide/eng- image/dockerfile_best-practices/
  • 68. Managing docker images ● Build the image – In the folder with a Dockerfile execute – Executed actions ● Create a new container with base image ● Execute commands and copy app files ● Create a new container with the result $ docker build -t myfirstimage .
  • 69. Managing docker images ● Run the new image – Open http://127.0.0.1:9000/ in the browser – Windows and Mac users with Toolbox use the IP $ docker run -p 9000:5000 myfirstimage * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
  • 70. Managing docker images ● Build the image again – Change some HTML in templatesindex.html – Create the image again – The steps that doesn't change are not executed again – The image is created very quickly because only the files copy is perfomed $ docker build -t myfirstimage .
  • 71. Volumes ● Volumes – Allow sharing files between host and container – Execute a container to show an nonexistent file – Create a text file $ docker run alpine cat /data/file.txt cat: can't open '/data/file.txt': No such file or directory $ echo "My file" >> file.txt
  • 72. Volumes Volumes ● Mount a host folder inside a container folder ● Host contents replace container contents of that folder ● Containers can write files in volumes to be available in the host $ sudo docker run -v $PWD:/data alpine cat /data/file.txt My file
  • 73. Volumes ● Volumes – Docker images use volumes to read files from host – Official NGINX container can serve host files using http ● Serving current folder files ($PWD) ● Go to http://127.0.0.1:9000/file.txt https://hub.docker.com/_/nginx/ $ docker run -p 9000:80 -v $PWD:/usr/share/nginx/html:ro -d nginx
  • 74. Volumes ● Volumes – Docker Toolbox for Win or Mac only allow folders inside user folder to be used as volume – You can use other folders but have to configure shared folders in VirtualBox https://hub.docker.com/_/nginx/
  • 75. •Containers main use cases – Net service ● Executed in background long time... ● Used through network ● Ex: Databases, web servers... – Command ● Execute a single command and stop ● Read and write files from host with volumes ● Ex: Java Compiler, jekyll, ffmpeg... Docker container usage
  • 76. •Docker for building software – A container can have all needed environment to execute a developer tool – For example, you can have the compiler and the test dependencies in a container – You can clone a git repository and execute the (dockerized) compiler without install any software in your host Docker for software developers
  • 77. •Dockerized Java Maven – Clone a maven repo – Compile and exec tests Docker for software developers $ git clone https://github.com/jglick/simple-maven-project-with-tests.git $ cd simple-maven-project-with-tests $ docker run --rm -v $PWD:/data -w /data maven mvn package
  • 78. •Dockerized Java Maven Docker for software developers $ docker run --rm -v $PWD:/data -w /data maven mvn package https://hub.docker.com/_/maven/ --rm Remove container when execution finish
  • 79. •Dockerized Java Maven Docker for software developers $ docker run --rm -v $PWD:/data -w /data maven mvn package https://hub.docker.com/_/maven/ --w Working dir for the command
  • 80. •Dockerized Java Maven Docker for software developers $ docker run --rm -v $PWD:/data -w /data maven mvn package https://hub.docker.com/_/maven/ maven Official Maven image
  • 81. •Dockerized Java Maven Docker for software developers $ docker run --rm -v $PWD:/data -w /data maven mvn package https://hub.docker.com/_/maven/ mvn package Maven command
  • 82. •Dockerized Java Maven – Jar package is generated in /target folder in host – As container is executed with root user, generated files are owned by root. – Change to your user Docker for software developers simple-maven-project-with-tests-1.0-SNAPSHOT.jar https://hub.docker.com/_/maven/ sudo chown -R username:group target
  • 83. •Advantages of dockerized dev tools – Avoid several developers having different versions of such tools – It is very easy to test the same code in different versions (Java 7, Java 8...) – Reduce tools configuration problems.You can compile and execute a project easily – The same tools can be executed in development laptops and also in CI environment Docker for software developers
  • 84. Docker for software developers
  • 85. •Docker in Continuous Integration – If you execute dev tools in containers, it is very easy to compile, test and package in CI environment – Only have to execute the same command in laptop and CI environment – If a tool changes, only have to change the command, it is not necessary to install anything Docker in CI servers
  • 86. https://jenkins.io/ •Docker in Continuous Integration Docker in CI servers
  • 87. ● Jenkins installation – You need Java – Go to https://jenkins.io/ – Download LTS Release Docker in CI servers
  • 92. ● Create new Jenkins job – Create a job with pipeline – Pipeline: ● Clone git repository ● Compile, test and package Java project ● Copy test results to Jenkins Jenkins Job
  • 93. Creamos una nueva tarea para descargar el proyecto y ejecutar los tests Jenkins Job
  • 96. node { // Mark the code checkout 'stage'.... stage 'Checkout' // Get some code from a GitHub repository git url: 'https://github.com/jglick/simple-maven-project-with-tests.git' // Mark the code build 'stage'.... stage 'Build' // Run the maven build sh "docker run --rm -v $PWD:/data -w /data maven mvn package" step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml']) } Pipeline Jenkins Job
  • 100. Successful finished job build (test passed) Jenkins Job
  • 101. Clic on build to see details Jenkins Job
  • 103. Repository clone and dockerized maven execution Jenkins Job
  • 104. ● Advantages of using docker in CI – CI server just need docker installed, nothing more – All tools needed by devs are containerized – Tools are downloaded (and cached) automatically when needed – Several languages/stacks/dependencies can be used in the same CI server without conflicts – Sysadmins do not need to give access to CI server to developers (enforcing security) Docker in CI servers
  • 105. ● Some issues of using docker in CI – Issue: By default project dependencies have to be downloaded in every build ● Solution: Use a host folder as cache – Issue: Old docker images waste HD space ● Solution: Use docker garbage collector (as you can download images when needed) – Issue: Window tools can’t be dockerized in linux containers ● Solution: Use portable tools as much as possible ;) Docker in CI servers
  • 106. ● Docker plugins for Jenkins – Docker Plugin ● https://wiki.jenkins-ci.org/display/JENKINS/Docker+Plugin – Docker build step plugin ● https://wiki.jenkins-ci.org/display/JENKINS/Docker+build+step+plugin – CloudBees Docker Custom Build Environment Plugin ● https://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Docker+Custom+Buil d+Environment+Plugin – Docker Slaves Plugin ● https://wiki.jenkins-ci.org/display/JENKINS/Docker+Slaves+Plugin – Yet Another Docker Plugin: ● https://wiki.jenkins-ci.org/display/JENKINS/Yet+Another+Docker+Plugin Docker in CI servers
  • 107. ● Conclusions – Docker containers are changing the way we develop, build, test and ship software – Containers allow developers to use the same dev tools and execute the project in the same environment – Containers ease the configuration and share of CI servers – If Continuous Integration is easier to use, more projects will use it and more test will be executed Docker in CI servers
  • 108. Thanks! Do you have any question?