Slide 1

Slide 1 text

Tech Talks: docker

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

Introduction ● Backend Engineer at Xtend Indonesia ● CTO of TestMate ● Member of Indonesian Bioinformatics and Biodiversity Society ● Google Developer Groups Medan ● Open source enthusiast and Communities Fellow ● Tech Background: Backend stuff, IaaS & PaaS Cloud, DevOps, more at https://fikihfirmansyah.my.id

Slide 4

Slide 4 text

Apa yang akan dibahas - Perkenalan fitur docker - Perbandingan dengan sistem lain - Tutorial docker sederhana - Dockerfile

Slide 5

Slide 5 text

Apa yang tidak akan dibahas - Memanfaatkan docker di real-life - Implementasi infrastruktur docker - Implementasi teknis lanjut

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

- Mudah dipelajari - Paus nya lucu - Dibikin pakai go

Slide 9

Slide 9 text

serius :)

Slide 10

Slide 10 text

Perubahan arsitektur

Slide 11

Slide 11 text

Fitur - images ● Ngebungkus setiap aplikasi dalam “kotak” yang sama (dependencies dan bisa dijalankan di mana saja) ● Mengisolasi berbagai hal dari satu sama lain ● Prosedur pembuatan yang terstandarisasi (Dockerfile)

Slide 12

Slide 12 text

Containers

Slide 13

Slide 13 text

Fitur - containers ● Mengelola kontainer ○ Menjalankan & menghentikan ○ Menyimpan & memuat (dari file) ● Memasang volume ○ Sharing data ○ Persistensi data ● Membuat Jaringan yang menghubungkan antar containers

Slide 14

Slide 14 text

Works on everyone's machine

Slide 15

Slide 15 text

Isolation

Slide 16

Slide 16 text

Portability

Slide 17

Slide 17 text

Fitur - workflow ● Docker daemon dan CLI ● Docker hub dan registry ● Image versioning (pull, commit, pull, layers)

Slide 18

Slide 18 text

Docker vs VM

Slide 19

Slide 19 text

secara sederhana

Slide 20

Slide 20 text

Ringan dan cepat

Slide 21

Slide 21 text

Sharing OS

Slide 22

Slide 22 text

Not really a VM

Slide 23

Slide 23 text

Why docker? Why not lxc?

Slide 24

Slide 24 text

Why docker? Why not lxc?

Slide 25

Slide 25 text

Why docker? Why not lxc?

Slide 26

Slide 26 text

Docker tutorial

Slide 27

Slide 27 text

Pull it! $ docker pull busybox ● Search docker registry for repository of given name ● Downloads the repository ● Pulls only changes

Slide 28

Slide 28 text

Pull it! $ docker pull busybox ● Search docker registry for repository of given name ● Downloads the repository ● Pulls only changes next time

Slide 29

Slide 29 text

Pull it! $ docker pull busybox ● Search docker registry for repository of given name ● Downloads the repository ● Pulls only changes next time

Slide 30

Slide 30 text

RUN!

Slide 31

Slide 31 text

Run it! $ docker run busybox:ubuntu- 14.04 echo "hello" ● Make sure that image is available (downloads if not found) ● Create a container ● Run a command

Slide 32

Slide 32 text

Run it! $ docker run -it busybox:ubuntu- 14.04 sh ● -it → makes container interactive ● Create a container ● Give you a shell access

Slide 33

Slide 33 text

More complicated example ● Run laravel project in a container ● Run it as a daemon ● ● Bind it to network Make storage persistent

Slide 34

Slide 34 text

Run it! $ docker run -d -v /var/docker/redis:/da ta -p 6379:6379 --name=redis dockerfile/redis ● -d → launch as daemon ● -v /var/docker/redis:/data → mount directories ● -p 6379:6379 → forward ports

Slide 35

Slide 35 text

Run it! $ docker run -d -v /var/docker/redis:/da ta -p 6379:6379 --name=redis dockerfile/redis ● -d → launch as daemon ● -v /var/docker/redis:/data → mount directories ● -p 6379:6379 → forward ports

Slide 36

Slide 36 text

Run it! $ docker run -d -v /var/docker/redis:/da ta -p 6379:6379 --name=redis dockerfile/redis ● -d → launch as daemon ● -v /var/docker/redis:/data → mount directories ● -p 6379:6379 → forward ports

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

Watch it! $ docker ps Prints out information about docker containers

Slide 39

Slide 39 text

Watch it! $ docker ps -a Prints out information about all docker containers: ● Running ● Exited

Slide 40

Slide 40 text

Watch it! $ docker logs -t --follow romantic_enstein ● Get logs from stdin/stdout of container ● -t → show timestamp ● --follow → similar to tail -f

Slide 41

Slide 41 text

Watch it! $ docker inspect romantic_enstein ● Get info about container ● Environment variables ● Ports Links

Slide 42

Slide 42 text

Watch it! nsenter ssh ● nsenter uses namespaces ● Ssh needs ssh server inside

Slide 43

Slide 43 text

Tidy up docker rm docker rmi ● Docker images use lots of space ● Docker images can clog all your available space on server (no more pulling from registry)

Slide 44

Slide 44 text

Repository workflow docker diff docker commit attero/stuff:my-tag ● Versioning! Tags ● Multiple versions Push & pull

Slide 45

Slide 45 text

What we learned so far ● Repository workflow ○ Pull ○ Commit ○ Push ● Tidying up after containers ○ Rm ○ Rmi ● Monitoring ○ Ps ○ Logs ○ Inspect ○ Top ● Running containers ○ Interactive ○ Daemon ○ Mounting ○ Forwarding

Slide 46

Slide 46 text

Containers are nice :)

Slide 47

Slide 47 text

How about automation?

Slide 48

Slide 48 text

DOCKERFILE

Slide 49

Slide 49 text

DOCKERFILE

Slide 50

Slide 50 text

DOCKERFILE -Version control -Automation -Portability

Slide 51

Slide 51 text

DOCKERFILE # Use the official Node.js 14 image as a base FROM node:14 # Set the working directory in the container WORKDIR /usr/src/app # Copy package.json and package-lock.json (if available) to the working directory COPY package*.json ./ # Install app dependencies RUN npm install # Bundle app source inside the Docker image COPY . . # Expose port 3000 to the outside once the container has launched EXPOSE 3000 # Define the command to run the app CMD ["node", "index.js"]

Slide 52

Slide 52 text

DOCKERFILE Every command in Dockerfile is run on a different container

Slide 53

Slide 53 text

DOCKERFILE Cache! use it, save lots of time not changed layers are reused

Slide 54

Slide 54 text

DOCKERFILE ● short ● good base image ● most changing things at the bottom

Slide 55

Slide 55 text

Q & A