Upgrade to Pro — share decks privately, control downloads, hide ads and more …

My Docker Best Practice (2016 Winter Short Vers...

My Docker Best Practice (2016 Winter Short Version)

Seigo Uchida

March 05, 2016
Tweet

More Decks by Seigo Uchida

Other Decks in Technology

Transcript

  1. # Dockerfile # OK CMD ["nginx"] CMD exec nginx #

    NG CMD nginx Ͳ͏΍ͬͯ? stop_signal
  2. Ͳ͏΍ͬͯ? # Run a container that has data $ docker

    run -d -name minecraft \ -v /data/world minecraft # Backup with dockup container $ docker run —rm --env-file env.txt \ —volumes-from minecraft \ tutum/dockup Dockup
  3. Ͳ͏΍ͬͯ? # Run monitoring agent $ docker run -d \

    -h `hostname` \ -e API_KEY=<KEY> \ - /var/run/docker.sock:/var/run/docker.sock \ - /proc/:/host/proc/:ro \ - /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \ datadog/docker-dd-agent:latest Datadog
  4. Ͳ͏΍ͬͯ? # Run log collector $ docker run -d -p

    24224:24224 fluent/fluentd # Send container log to log collector $ docker run -d —log-driver=fluentd nginx Fluentd
  5. Ͳ͏΍ͬͯ? # DB migration $ docker run —rm rails rake

    db:migrate # Rails console $ docker run -it —rm rails rails console # AWS CLI $ docker run --rm \ quay.io/spesnova/aws-cli:latest \ aws s3 ls one-off container
  6. Ͳ͏΍ͬͯ? # Dockerfile COPY ./nginx.conf.tmpl /etc/nginx/nginx.conf.tmpl ENTRYPOINT [ "render", \

    "/etc/nginx/nginx.conf", "--", "/usr/sbin/nginx" ] Entrykit # nginx.conf.tmpl worker_processes {{ var "WORKER_PROCESSES" | default "1" }};
  7. Ͳ͏΍ͬͯ? # Preparation for maintenance $ kubectl drain node-00 node

    "node-00" cordoned pod "example-fcgm3" deleted pod "example-pi8rq" deleted node "node-00" drained # Do maintenance # Make the node schedulable $ kubectl uncordon node-00 node "node-00" uncordoned kubernetes Drain
  8. Ͳ͏΍ͬͯ? # Run Clair service $ docker run -p 6060:6060

    -p 6061:6061 -v /tmp:/tmp -v $PWD:/config \ quay.io/coreos/clair —config /config/config.yml # Run image scan $ ./analyze-local-images postgres … - Added by: aa0e4f075388ef6efa1cb6f243fa78b862201b3…. ### (Medium) CVE-2016-0402 - Link: https://security-tracker.debian.org/tracker/CVE-2016-0402 - Description: Unspecified vulnerability in the Java SE and Java SE ……. - Fixed version: 7u95-2.6.4-1~deb7u1 - Metadata: …… … Clair
  9. Ͳ͏΍ͬͯ? # Run Docker Benchmark for Security $ docker-compose run

    --rm docker-bench-security … INFO] 1 - Host Configuration [WARN] 1.1 - Create a separate partition for containers [PASS] 1.2 - Use an updated Linux Kernel [PASS] 1.5 - Remove all non-essential services from the host - Network [WARN] 1.6 - Keep Docker up to date [WARN] * Using 1.10.1, when 1.10.2 is current as of 2016-02-22 … docker/docker-bench-security
  10. • Graceful ʹࢭΊΑ͏ • backup΋migration΋ίϯςφͰ • ઃఆ͸ Entrykit Ͱ؀ڥม਺ʹ •

    ϗετϚγϯͷӡ༻Λ๨ΕΔͳ • ܧଓత੬ऑੑεΩϟϯ • SecurityBenchmark Λྲྀͯ͠ΈΑ͏ ϓϥΫςΟε