Offizielle Docker Images – ein Erfahrungsbericht

A presentation at Continuous Lifecycle in November 2018 in Mannheim, Germany by Philipp Krenn

Slide 1

Slide 1

Offizielle Docker Images ein Erfahrungsbericht Philipp Krenn @xeraa

Slide 2

Slide 2

Infrastructure | Developer

Slide 3

Slide 3

Who uses Docker?

Slide 4

Slide 4

Who uses Docker in production?

Slide 5

Slide 5

Who uses stateful Docker images?

Slide 6

Slide 6

Who uses our images?

Slide 7

Slide 7

Who uses our stack with other images?

Slide 8

Slide 8

Docker: the world's most heavily funded college project Internal quote from Slack

Slide 9

Slide 9

Slide 10

Slide 10

Content "Official" Base Images Release Policy Security & Stability Customization Orchestration

Slide 11

Slide 11

Docker Hub "official"

Slide 12

Slide 12

What do you get? docker pull elasticsearch:X Same for Kibana and Logstash

Slide 13

Slide 13

It's Complicated Docker Inc Deprecated Replicated

Slide 14

Slide 14

Slide 15

Slide 15

Slide 16

Slide 16

Slide 17

Slide 17

Custom Registry docker.elastic.co

Slide 18

Slide 18

I’m surprised more people don’t just host their own container registries since doing that is faster than every cloud offering and docker hub https://twitter.com/jessfraz/status/978449365261082625

Slide 19

Slide 19

Our Motivation Download statistics Speed & reliability

Slide 20

Slide 20

Slide 21

Slide 21

https://www.docker.elastic.co

Slide 22

Slide 22

Problems Some broken tooling like automated builds, Kitematic,... China IPv6

Slide 23

Slide 23

Slide 24

Slide 24

https://hub.docker.com/r/elastic/ elasticsearch/ kibana/ *beat/ logstash/ apm-server/

Slide 25

Slide 25

Base Images

Slide 26

Slide 26

Elasticsearch Alpine

Slide 27

Slide 27

Kibana Beats Logstash Ubuntu

Slide 28

Slide 28

Common base image in 5.4+ CentOS 7

Slide 29

Slide 29

https://github.com/elastic/elasticsearch-docker/blob/master/templates/Dockerfile.j2 FROM centos:7 AS prep_es_files ENV PATH /usr/share/elasticsearch/bin:$PATH RUN curl -s https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz | \ tar -C /opt -zxf ENV JAVA_HOME /opt/jdk-11.0.1 RUN groupadd -g 1000 elasticsearch && \ adduser -u 1000 -g 1000 -d /usr/share/elasticsearch elasticsearch

Slide 30

Slide 30

Upside Similar setup Shared layers JVM large anyway

Slide 31

Slide 31

Slide 32

Slide 32

Downside Size

Slide 33

Slide 33

$ docker images REPOSITORY docker.elastic.co/kibana/kibana docker.elastic.co/elasticsearch/elasticsearch docker.elastic.co/beats/filebeat docker.elastic.co/kibana/kibana docker.elastic.co/elasticsearch/elasticsearch docker.elastic.co/beats/filebeat docker.elastic.co/kibana/kibana docker.elastic.co/elasticsearch/elasticsearch docker.elastic.co/beats/filebeat docker.elastic.co/kibana/kibana docker.elastic.co/elasticsearch/elasticsearch docker.elastic.co/beats/filebeat TAG 6.5.0 6.5.0 6.5.0 6.2.4 6.2.4 6.2.4 5.6.13 5.6.13 5.6.13 5.3.3 5.3.3 5.3.3 IMAGE ID fcc1f039f61c ff171d17e77c aee067f4a241 327c6538ba4c 7cb69da7148d 26a00abcde82 59fcc69d2cc6 21673573a265 2aec30f6b3fc ffe778f7e489 5857f98b5920 c01be8a8f630 SIZE 727MB 774MB 299MB 933MB 515MB 319MB 653MB 525MB 284MB 679MB 165MB 232MB

Slide 34

Slide 34

5.3 5.6 6.2 6.5 ES 165MB 525MB 515MB 774MB Kibana 679MB 653MB 933MB 727MB Filebeat 232MB 284MB 319MB 299MB

Slide 35

Slide 35

Does it matter? stateful vs stateless

Slide 36

Slide 36

What to include?

Slide 37

Slide 37

Single image for 5.x Platinum trial

Slide 38

Slide 38

Three flavors 6.0 to 6.2 * Basic , OSS, Platinum trial * Default

Slide 39

Slide 39

Two flavors 6.3+ * Basic / Platinum trial , OSS * Default

Slide 40

Slide 40

Future

Slide 41

Slide 41

Multiple base images?

Slide 42

Slide 42

Windows?!

Slide 43

Slide 43

Release Policy

Slide 44

Slide 44

No :latest

Slide 45

Slide 45

Zombies ideas that should have been killed by evidence, but keep shambling along

Slide 46

Slide 46

6 and 6.4?

Slide 47

Slide 47

What's in a tag? docker.elastic.co/elasticsearch/elasticsearch docker.elastic.co/beats/filebeat docker.elastic.co/kibana/kibana 5.3.3 5.3.3 5.3.3 5857f98b5920 c01be8a8f630 ffe778f7e489 4 months ago 5 months ago 5 months ago

Slide 48

Slide 48

Currently Overwrite tag

Slide 49

Slide 49

Label Schema LABEL org.label-schema.schema-version="1.0" \ org.label-schema.vendor="Elastic" \ org.label-schema.name="elasticsearch" \ org.label-schema.version="{{ elastic_version }}" \ org.label-schema.url="https://www.elastic.co/products/elasticsearch" \ org.label-schema.vcs-url="https://github.com/elastic/elasticsearch-docker" \ {% if image_flavor == 'oss' -%} license="Apache-2.0" {% else -%} license="Elastic License" {% endif -%}

Slide 50

Slide 50

Base image & JVM direct dependencies

Slide 51

Slide 51

Future Add image version?

Slide 52

Slide 52

Security & Stability

Slide 53

Slide 53

Run Elasticsearch as root

Slide 54

Slide 54

Cockroaches claims that disappear for a while when proved wrong, but just keep on coming back

Slide 55

Slide 55

Mode Production: Clusterable Development: Local network

Slide 56

Slide 56

"Docker" mode discovery.type=single-node

Slide 57

Slide 57

Bootstrap checks are here to stay

Slide 58

Slide 58

6.0+ no more default credentials

Slide 59

Slide 59

6.x Security non-trial requires certificates

Slide 60

Slide 60

The container runs Elasticsearch as user elasticsearch using uid:gid 1000:1000. https://www.elastic.co/guide/en/elasticsearch/reference/current/ docker.html

Slide 61

Slide 61

Slide 62

Slide 62

Slide 63

Slide 63

Slide 64

Slide 64

Don't mutate the bind mounted local directory

Slide 65

Slide 65

Those who do not understand Unix are condemned to reinvent it, poorly. — Henry Spencer

Slide 66

Slide 66

Docker default value? LimitNOFILE & LimitNPROC

Slide 67

Slide 67

infinity https://github.com/moby/moby/commit/ 8db61095a3d0bcb0733580734ba5d54bc27a614d (July 2016)

Slide 68

Slide 68

Test $ docker run --rm centos:7 /bin/bash -c \ 'ulimit -Hn && ulimit -Sn && ulimit -Hu && ulimit -Su' 1048576 1048576 unlimited unlimited

Slide 69

Slide 69

Limit for virtual memory? vm.max_map_count

Slide 70

Slide 70

Test $ docker run --rm centos:7 /bin/bash -c \ 'sysctl vm.max_map_count' vm.max_map_count = 262144 Must be set on the host

Slide 71

Slide 71

Combine two new systems to get chaos & despair

Slide 72

Slide 72

Docker is a leaky abstraction

Slide 73

Slide 73

Slide 74

Slide 74

Customization

Slide 75

Slide 75

Feature Request if [ -f /custom/user_init.sh ] then . /custom/user_init.sh fi Or customization through environment variables

Slide 76

Slide 76

No Runtime Mutation

Slide 77

Slide 77

Dockerfile ARG ELASTIC_VERSION FROM docker.elastic.co/elasticsearch/elasticsearch:${ELASTIC_VERSION} RUN bin/elasticsearch-plugin install analysis-phonetic --batch ARG ELASTIC_VERSION RUN bin/elasticsearch-plugin install \ https://github.com/spinscale/elasticsearch-ingest-langdetect/releases/download/ ${ELASTIC_VERSION}.1/ingest-langdetect-${ELASTIC_VERSION}.1.zip --batch

Slide 78

Slide 78

Generate Keystore $ docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" \ -v /Users/philipp/Desktop/demo/config/:/usr/share/elasticsearch/config/ \ -it docker.elastic.co/elasticsearch/elasticsearch:6.4.3 /bin/bash [root@1006ed50b646 elasticsearch]# ./bin/elasticsearch-keystore create Created elasticsearch keystore in /usr/share/elasticsearch/config [root@1006ed50b646 elasticsearch]# ./bin/elasticsearch-keystore add test Enter value for test: [root@1006ed50b646 elasticsearch]# exit exit $ cat config/elasticsearch.keystore ??lelasticsearch.keystore?@g?o!?$?K?Lf?w?VAEŠԨm?[?a6?B??? y?,!В}??Ħ?ǣ?AU=?C?:?o? ?W?O8?}U?;p?ӷ???cQ????7?JY? 2A?:???ZUY??2V?9?ϧ??(??0?q\

Slide 79

Slide 79

Mount Keystore (Docker Compose) elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTIC_VERSION} secrets: - source: elasticsearch.keystore target: /usr/share/elasticsearch/config/elasticsearch.keystore

Slide 80

Slide 80

Orchestration

Slide 81

Slide 81

Who uses Kubernetes?

Slide 82

Slide 82

Who uses Swarm?

Slide 83

Slide 83

Who uses Mesos?

Slide 84

Slide 84

Who uses Nomad?

Slide 85

Slide 85

No orchestration yet

Slide 86

Slide 86

Kubernetes 1.8 allows dots in env vars https://github.com/kubernetes/kubernetes/issues/2707

Slide 87

Slide 87

Slide 88

Slide 88

Slide 89

Slide 89

Kubernetes has made huge improvements in the ability to run stateful workloads including databases and message queues, but I still prefer not to run them on Kubernetes. https://twitter.com/kelseyhightower/status/963413508300812295

Slide 90

Slide 90

Slide 91

Slide 91

Conclusion

Slide 92

Slide 92

"Docker is disrupting the industry"

Slide 93

Slide 93

"Can I run Elasticsearch on Docker?"

Slide 94

Slide 94

"Should I run Elasticsearch on Docker?"

Slide 95

Slide 95

Even when stateful services do the right things managing state is still hard. Mixing stateful and stateless applications on the same cluster elevates the complexity of the entire cluster. Cluster security and upgrades become much harder. https://twitter.com/kelseyhightower/status/963417215608369153

Slide 96

Slide 96

Quick Quiz What do you get?

Slide 97

Slide 97

docker pull elastic/elasticsearch

Slide 98

Slide 98

$ docker pull elastic/elasticsearch Using default tag: latest Error response from daemon: manifest for elastic/elasticsearch:latest not found

Slide 99

Slide 99

docker pull logstash:alpine

Slide 100

Slide 100

docker pull metricbeat:6.4.3

Slide 101

Slide 101

$ docker pull metricbeat:6.4.3 Error response from daemon: pull access denied for metricbeat, repository does not exist or may require 'docker login'

Slide 102

Slide 102

docker pull elastic/metricbeat:6.4.3

Slide 103

Slide 103

docker pull docker.elastic.co/apm/apm-server:6.4.3

Slide 104

Slide 104

"Aggregierte Logging-Patterns" Tomorrow 15:45 @ Gustav Mahler II

Slide 105

Slide 105

Questions & Discussion Philipp Krenn @xeraa