Slide 1

Slide 1 text

WORKSHOP Rafael Dutra

Slide 2

Slide 2 text

WHO AM I? ● Rafael Dutra ● SysAdmin and DevOps Enthusiast ● Security Information - UNISINOS 2008 - ? ● Linux user since 2005 ● Docker user since 2015 ● PHP (Laravel)/Shell/Ruby

Slide 3

Slide 3 text

WORKING WITH/AT Vagrant, Puppet, Terraform, Continuous Integration, Continuous Deployment, Shell Scripting, Docker, AWS (learning) ... Shared Services Ops Team @crossover - https://crossover.com @jivesoftware - https://jivesoftware.com @aurea - https://www.aurea.com

Slide 4

Slide 4 text

AGENDA ● What’s Docker? ● Container vs Virtual Machine ● Why should I use Docker? ● Terminology ● Images and Layers ● Containers and Layers ● Dockerfile anatomy

Slide 5

Slide 5 text

WHAT'S DOCKER? ● Open Source technology ● Agility, accelerate software development and deployment ● Portability, eliminate the "works on my machine" ● Container is not Virtual Machine

Slide 6

Slide 6 text

CONTAINER VS VIRTUAL MACHINES

Slide 7

Slide 7 text

WHY SHOULD I USE DOCKER? ● Infrastructure as Code - IAC ● All application is an image ● Works on my machine, no more! ● Set up locally the same environment that you have in production, or any other environment ● Tests, a lot of them ● Community

Slide 8

Slide 8 text

TERMINOLOGY ● Images = is our “how it was built” / what we want to run ● Containers = runs images in a dynamic way. By dynamic I meant: multiple containers can run the same image doing different things. ● Volumes = where we want to store our data, could be our physical directory or a docker volume

Slide 9

Slide 9 text

IMAGES AND LAYERS

Slide 10

Slide 10 text

CONTAINERS AND LAYERS

Slide 11

Slide 11 text

DOCKERFILE # base image FROM nginx # copy a file to a specific directory COPY index.html /usr/share/nginx/html # running the application CMD ["nginx", "-g", "daemon off;"]

Slide 12

Slide 12 text

HANDS ON

Slide 13

Slide 13 text

HANDS ON AGENDA ● Docker installation ● The basics, running containers ● Interacting with containers ● Dockerfile ● Using volumes ● Docker Compose

Slide 14

Slide 14 text

DOCKER INSTALLATION ● Ubuntu: https://goo.gl/YFDkpv ● Debian: https://goo.gl/T6pmJd curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh

Slide 15

Slide 15 text

DOCKER BASICS Full commands docker

Slide 16

Slide 16 text

DOCKER BASICS Need a medic? ask for help docker --help

Slide 17

Slide 17 text

DOCKER BASICS Running our first container docker run alpine hostname

Slide 18

Slide 18 text

DOCKER BASICS Running our second container docker run hello-world

Slide 19

Slide 19 text

DOCKER BASICS Everything comes from an image docker run alpine hostname

Slide 20

Slide 20 text

DOCKER BASICS To list all images docker image ls

Slide 21

Slide 21 text

DOCKER BASICS To search an image docker search alpine

Slide 22

Slide 22 text

DOCKER BASICS To pull (download) an image docker image pull ubuntu

Slide 23

Slide 23 text

DOCKER BASICS To pull (download) an specific image version docker image pull ubuntu:17.10

Slide 24

Slide 24 text

DOCKER BASICS Running our first web container docker run --detach --publish 45000:80 nginx ● action that we want to do ● options to detach (run it in background) and publish ports ● port that we want to access in our machine ● port running in the container ● image we are using at this moment

Slide 25

Slide 25 text

MANIPULATE CONTAINERS To list running containers docker container ls

Slide 26

Slide 26 text

MANIPULATE CONTAINERS To list all containers docker container ls -a

Slide 27

Slide 27 text

MANIPULATE CONTAINERS Stopping a container docker container stop

Slide 28

Slide 28 text

MANIPULATE CONTAINERS Starting a container docker container start

Slide 29

Slide 29 text

MANIPULATE CONTAINERS Interacting with them docker run --interactive --tty ubuntu /bin/bash

Slide 30

Slide 30 text

MANIPULATE CONTAINERS Executing …. something without enter in a container docker exec

Slide 31

Slide 31 text

MANIPULATE CONTAINERS Attaching. important: Containers needs some “bash/sh” running docker attach

Slide 32

Slide 32 text

MANIPULATE IMAGES To remove an image Important: Only containers removed docker image rm alpine

Slide 33

Slide 33 text

CREATING IMAGES (Dockerfile) FROM php:7.2.5-cli-alpine3.7 CMD ["php", "--version"]

Slide 34

Slide 34 text

CREATING IMAGES docker build --tag fossday/php:7.2 .

Slide 35

Slide 35 text

RUN FORREST … RUN docker run --rm fossday/php:7.2

Slide 36

Slide 36 text

RUN FORREST … RUN docker run --rm fossday/php:7.2 --help

Slide 37

Slide 37 text

RUN FORREST … RUN WITH MATH

Slide 38

Slide 38 text

RUN FORREST … RUN docker run --rm \ -v $(pwd)/soma.php:/root/soma.php \ fossday/php:7.2 \ php -f /root/soma.php

Slide 39

Slide 39 text

CLEANING Remove all containers that are in stopped state (dangling) docker container prune

Slide 40

Slide 40 text

DOCKER COMPOSE ● Orchestrate containers ● YAML ● Single file: docker-compose.yaml ● Multi containers

Slide 41

Slide 41 text

DOCKER COMPOSE INSTALLATION https://goo.gl/8mbW87

Slide 42

Slide 42 text

DOCKER COMPOSE docker-compose up -d

Slide 43

Slide 43 text

QUESTIONS ? HERE WE GO

Slide 44

Slide 44 text

GET IN TOUCH https://rafaeldutra.me https://docker.rafaeldutra.me https://linkedin.com/in/rafaeldutra @raffaeldutra [email protected] https://github.com/raffaeldutra https://speakerdeck.com/raffaeldutra

Slide 45

Slide 45 text

THANK YOU SEE YOU LATER