Slide 1

Slide 1 text

(without introducing more risk) What's Inside That Container? Puppet Gareth Rushgrove Containers and config management in the real world

Slide 2

Slide 2 text

(without introducing more risk) @garethr

Slide 3

Slide 3 text

(without introducing more risk) Gareth Rushgrove

Slide 4

Slide 4 text

(without introducing more risk) What we’ll cover This talk

Slide 5

Slide 5 text

- What is configuration management? - Docker base image usage - The problem with containers as black boxes - Ideas and demos Gareth Rushgrove

Slide 6

Slide 6 text

(without introducing more risk) Useful background What is Configuration Management?

Slide 7

Slide 7 text

- 1950s research - 1960s 480 series - 1991 MIL-HDBK-61 - 1998 ANSI-EIA-649 Gareth Rushgrove

Slide 8

Slide 8 text

- Identification - Control - Status accounting - Verification and audit Gareth Rushgrove Military Handbook Configuration Management Guidance MIL-HDBK-61B

Slide 9

Slide 9 text

Configuration management verifies that a system is identified and documented in sufficient detail Gareth Rushgrove National Consensus Standard for Configuration Management EIA-649

Slide 10

Slide 10 text

Configuration management verifies that a system performs as intended Gareth Rushgrove National Consensus Standard for Configuration Management EIA-649

Slide 11

Slide 11 text

NOTE: Not a tool, a practice Gareth Rushgrove

Slide 12

Slide 12 text

(without introducing more risk) And where to find them Docker Base Images

Slide 13

Slide 13 text

(without introducing more risk) Gareth Rushgrove Docker Hub API $ curl -s https://registry.hub.docker.com/v2/... ...repositories/library/ubuntu/ | jq .pull_count

Slide 14

Slide 14 text

Gareth Rushgrove Image downloads

Slide 15

Slide 15 text

What about other popular official images? Node (32,523,647), Java (16,635,049), etc. Currently based on Debian too Gareth Rushgrove

Slide 16

Slide 16 text

Gareth Rushgrove Image size

Slide 17

Slide 17 text

(without introducing more risk) Gareth Rushgrove Count files $ find -maxdepth 1 -type d | while read -r dir; do printf "%s:\t" "$dir"; find "$dir" -type f | wc -l; done

Slide 18

Slide 18 text

(without introducing more risk) Gareth Rushgrove Count packages $ dpkg -l | grep ^ii | wc -l $ dnf list installed $ rpm -qa | wc -l $ apk info | wc -l

Slide 19

Slide 19 text

Gareth Rushgrove Image contents

Slide 20

Slide 20 text

(without introducing more risk) Thanks David Gageot

Slide 21

Slide 21 text

(without introducing more risk) Gareth Rushgrove Popular on GitHub SELECT RTRIM(LTRIM(SUBSTR(line, 5))) AS line_group.base_image FROM ( SELECT SPLIT(dockerfile, '\n') AS line FROM [github.dockerfiles_content] HAVING LEFT(line, 5) = 'FROM ' ) SELECT image, count(*) AS count FROM ( SELECT FIRST(SPLIT(line_group.base_image, ':')) AS image FROM [github.images] ) GROUP BY image ORDER BY count DESC

Slide 22

Slide 22 text

Gareth Rushgrove Image GitHub popularity

Slide 23

Slide 23 text

Gareth Rushgrove Usage growth

Slide 24

Slide 24 text

(without introducing more risk) Thanks to Microbadger

Slide 25

Slide 25 text

Gareth Rushgrove Hub image sample

Slide 26

Slide 26 text

Gareth Rushgrove

Slide 27

Slide 27 text

The majority of people using Docker are using images containing an entire operating system filesystem Gareth Rushgrove

Slide 28

Slide 28 text

Alpine usage is growing more rapidly than others, but starting from a much smaller install base Gareth Rushgrove

Slide 29

Slide 29 text

Scratch, or other approaches like Nix, appear to occupy a small niche Gareth Rushgrove

Slide 30

Slide 30 text

Windows and Windows Nano images will undoubtedly become more common over the next year or so Gareth Rushgrove

Slide 31

Slide 31 text

Debian derivatives account for the majority of images today Gareth Rushgrove

Slide 32

Slide 32 text

(without introducing more risk) What does this all mean to me? Problems

Slide 33

Slide 33 text

(without introducing more risk) You don’t know, and that’s a problem

Slide 34

Slide 34 text

(without introducing more risk) Visibility and control are critical

Slide 35

Slide 35 text

(without introducing more risk) What you don’t know can hurt you

Slide 36

Slide 36 text

(without introducing more risk) Vulnerable images on Docker Hub

Slide 37

Slide 37 text

(without introducing more risk) Not quite so simple

Slide 38

Slide 38 text

Can you tell me all the versions of OpenSSL you have in production right now? Gareth Rushgrove

Slide 39

Slide 39 text

Containers are a black box Gareth Rushgrove

Slide 40

Slide 40 text

Containers are a black box from the point of view of the scheduler Gareth Rushgrove

Slide 41

Slide 41 text

Containers are NOT a black box from the point of view of the operator Gareth Rushgrove

Slide 42

Slide 42 text

These are all generally configuration management problems; identification, control, status accounting, verification and audit Gareth Rushgrove

Slide 43

Slide 43 text

(without introducing more risk) Experiments and proof-of-concept work Ideas

Slide 44

Slide 44 text

Immutability means we need to know what we put inside the box Gareth Rushgrove

Slide 45

Slide 45 text

(without introducing more risk) Tangent about immutability

Slide 46

Slide 46 text

It’s not enough to say ubuntu:16.04 Gareth Rushgrove

Slide 47

Slide 47 text

(without introducing more risk) LIVE DEMOS

Slide 48

Slide 48 text

(without introducing more risk) Gareth Rushgrove Embed inventory in image $ add-container-inventory centos garethr/centos-inventory ----> Using existing puppet-inventory volume ----> Generating inventory for image centos ----> Saving inventory to temporary image inventory-21042 ----> Committing new image to garethr/centos-inventory sha256:f84b3655252c946dfb888de2d74348afed97ef89d817e469adad3a ----> Cleaning up

Slide 49

Slide 49 text

(without introducing more risk) https://gist.github.com/garethr/ 922f6374015b59e0f6cd007f8b34eedf

Slide 50

Slide 50 text

(without introducing more risk) Gareth Rushgrove Read image inventory data $ docker run --rm garethr/centos-inventory cat /inventory.json | { { "title": "rpm", "resource": "package", "provider": “yum", "versions": [ "4.11.3-17.el7" ] }, { "title": “libuser", "resource": "package", "provider": “yum",

Slide 51

Slide 51 text

(without introducing more risk) Gareth Rushgrove Runtime and multi-OS $ docker exec an-opensuse-container cat /inventory.json | jq { { "title": "netcfg", "resource": "package", "provider": "zypper", "versions": [ "11.5-27.2" ] }, { "title": "shadow", "resource": "package", "provider": "zypper",

Slide 52

Slide 52 text

GIVEN all my containers now have an inventory WHAT things can I do with it? Gareth Rushgrove

Slide 53

Slide 53 text

Asking the black box what OS it contains? Gareth Rushgrove

Slide 54

Slide 54 text

(without introducing more risk) Gareth Rushgrove Use jq to query inventory $ docker run --rm garethr/centos-inventory \ cat /inventory.json | jq '.facts.operatingsystem' "CentOS"

Slide 55

Slide 55 text

What about a package search engine? Gareth Rushgrove

Slide 56

Slide 56 text

(without introducing more risk) Gareth Rushgrove Package search $ search-inventory rpm festive_edison rpm 4.11.3-17.el7 yum optimistic_shockley rpm 4.11.3-17.el7 yum condescending_swartz rpm 4.11.2-10.1 zypper festive_edison rpm-libs 4.11.3-17.el7 yum festive_edison rpm-python 4.11.3-17.el7 yum optimistic_shockley rpm-libs 4.11.3-17.el7 yum optimistic_shockley rpm-python 4.11.3-17.el7 yum festive_edison rpm-build-libs 4.11.3-17.el7 yum optimistic_shockley rpm-build-libs 4.11.3-17.el7 yum $ search-inventory package:openssl,provider:yum festive_edison openssl-libs 1:1.0.1e-51.el7_2.5 yum optimistic_shockley openssl-libs 1:1.0.1e-51.el7_2.5 yum

Slide 57

Slide 57 text

(without introducing more risk) Search packages across containers

Slide 58

Slide 58 text

(without introducing more risk) Gareth Rushgrove Search in BigQuery SELECT resources.title AS package, resources.versions AS version, facts.hostname AS hostname, facts.operatingsystem AS operatingsystem FROM inventory.sample WHERE resources.resource="package" AND resources.title="openssl"

Slide 59

Slide 59 text

checking containers for CVEs? Gareth Rushgrove

Slide 60

Slide 60 text

(without introducing more risk) Red Hat Security Data API

Slide 61

Slide 61 text

(without introducing more risk) Gareth Rushgrove CVE scanner $ scan-containers-for-cves python ---> Scanning package: python ---> CVEs found for python-2.7.5-34.el7 in festive_edison +---------------+----------+------------+-------------------+ | CVE | Severity | CVSS score | Date | +---------------+----------+------------+-------------------+ | CVE-2014-4650 | moderate | 5.0 | 23 June 2014 | | CVE-2013-1752 | moderate | 4.3 | 25 September 2012 | | CVE-2013-1753 | moderate | 4.3 | 25 September 2012 | | CVE-2014-7185 | low | 4.0 | 23 June 2014 | | CVE-2014-4616 | moderate | 4.0 | 19 May 2014 | +---------------+----------+------------+-------------------+ ---> Scanning package: python ---> CVEs found for python-2.7.5-34.el7 in optimistic_shockley +---------------+----------+------------+-------------------+

Slide 62

Slide 62 text

(without introducing more risk) https://gist.github.com/garethr/ d4f6e23ff19939e4877f441434ede8da

Slide 63

Slide 63 text

(without introducing more risk) If all you remember is Conclusions

Slide 64

Slide 64 text

Operators treating containers as black boxes are going to have a bad time Gareth Rushgrove

Slide 65

Slide 65 text

Beware the difference between the purity of linux containers and the pragmatic reality of Docker base images Gareth Rushgrove

Slide 66

Slide 66 text

When using containers we need to reconsider solutions to previously solved configuration management problems Gareth Rushgrove

Slide 67

Slide 67 text

(without introducing more risk) Questions? And thanks for listening