SlideShare a Scribd company logo
Bern
07th
September
Start your container
journey safely
Rachid
Zarouali
C.I.O Synolia
Docker Captain
Twitter / Slack : @xinity
rzarouali@gmail.com
● Hosts Security
●
● Image Management
●
● Container Security
●
● Opensource Tools
Agenda
Introduction
buckle up for safety
● security is :
○ Everyone's responsibility
○ Necessary
○ Is not hard
○ A never ending story
○
● But we are lazy when it’s come to it !!!!
○
Who, Why, How, When
Ecosystem
And many many more ….
Start your container journey safely
● docker run -d -v /:/srv ……
●
● docker run -d --cap-add=ALL …. (*)
●
● docker run -d --privileged ….
(*):
https://docs.docker.com/engine/reference/run/#runtime-privilege-a
nd-linux-capabilities
(bad) habits I
● docker exec -ti myapache bash
○ apt install mysql-server
○
● docker exec -ti mycontainer bash
○ apt full-upgrade
●
(bad) habits II
Security Topics
Docker Security Features :
○ Image building and Signing
○ Security Scanning
○ Docker Content Trust
○
Linux Security Features :
○ Kernel Capabilities
○ Seccomp
○ AppArmor
Back to basics
Anatomy of a container
Anatomy of a container
User Space:
● Binaries
● Libraries
● Dependencies
Kernel Space:
● Process tree
● Filesystem root
● Network
● Limits on resource
Anatomy of a container
Namespaces:
● The PID namespace stops
processes in one container from
seeing processes in another
container (or on the host)
● The User namespace allows
containers to run processes as
root inside the container but as
non-privileged users outside the
container (on the host)
Cgroups:
● Can limit the amount of CPU or
memory a container can use,
and prevent them from
consuming all system resource
Anatomy of a container
Namespaces
Cgroup Cgroup root directory
IPC System V IPC, POSIX message queues
Network Network devices, stacks, ports, etc.
Mount Mount points
PID Process IDs
User User and group IDs (disabled by default)
UTS Hostname and NIS domain name
Cgroups
Memory
CPU
Blkio
Cpuacct
Cpuset
Devices
Net_prio
Freezer
Docker Hosts
Docker hosts
● Different implementations
○ AtomicOS
○ CoreOS
○ RancherOS
○ LinuxKit ….
Docker hosts
● AtomicOS
○ Striped down fedora with docker
○ K8s oriented
○ Full containerOS
○ Integration with Cockpit/Openshift
○ ISO: ~ 900mb
Docker hosts
● CoreOS
○ Rkt / Docker support
○ Tricky management
○ Integration with tectonic
○ Acquired by RedHat
○ ISO: ~ 350 mb
Docker hosts
● RancherOS
Docker hosts
● RancherOS
○ Full Docker Based
○ Multiple console / engine
○ Stateless by default
○ Easy to manage
○ Integration with Rancher
○ ISO: 85mb
Docker hosts
● LinuxKit
○ Full Docker Based
○ K8s support
○ Highly stripped down
○ Modular build (moby project)
○ System developer oriented
○ ISO: < 30 mb
Docker hosts
Demo: host security
Docker images
Build, Ship, Run
Docker images
Image: several read-only layers build from a Dockerfile
Container: Image + read-write layer
I.e: `docker run -ti debian:stretch-slim bash`
Docker images
Docker images
More layers mean :
● larger image
● longer build, push and pull from a registry
Small images mean :
● faster build and deploy
● small surface of attack
Docker images
How to reduce layers number:
● Share base image as much as possible
● Limit data written to the layer (nothing unnecessary)
● Chain RUN statements
Docker images
FROM ubuntu:latest
LABEL maintainer abbyfull@amazon.com
RUN apt-get update -y && apt-get install -y python-pip
python-dev build-essential
COPY . /app
WORKDIR /app
RUN pip install –r requirements.txt
EXPOSE 5000
ENTRYPOINT ["python"]
CMD ["application.py"]
Docker images
FROM python:2.7-alpine
LABEL maintainer abbyfull@amazon.com
ONBUILD ADD requirements.txt /app
ONBUILD RUN pip install –r /app/requirements.txt
ONBUILD COPY . /app
WORKDIR /app
EXPOSE 5000
ENTRYPOINT ["python"]
CMD ["application.py"]
Docker images
Use minimalistic base images
● Smaller images reduce the attack surface
● The official Alpine base image is <5MB
Use official images as base images
● All official images are scanned for vulnerabilities
● Usually follow best practices
Use MultiStage Build as much as possible
/! generate smaller image, but not necessarily faster /!
Docker images
Pull images by digest ‘Image digests are a hash of the image’s config object )
● This makes them immutable
● If the contents of the image are changed/tampered with,
the digest will be different
Docker images
Demo: build, pull and more
Run your images
Dockerd requires root access
● Uses kernel features like namespaces
Verify root access of dockerd:
$ ps ufaxw | grep dockerd
Run your images
By default dockerd listens on /var/run/docker.sock
● Non-networked , local Unix socket
● Own by dockerd group
○ $ ls -l /var/run/docker.sock
○ srw-rw---- 1 root docker 0 Mar 30 09:15 /var/run/docker.sock
Run your images
● Non root user should be member of docker
group
/! don’t do `sudo docker ….` /!
○ $ sudo usermod -aG docker xinity
○ $ id xinity
Run your images
By default containers runs as root /!
$ docker container run -v /:/srv -it --rm alpine sh
# whoami
root
# id
uid=0(root) gid=0(root)
# rm -rf /srv/*
Run your images
By default root inside == root outside of a container
/! run your containers unprivileged /!
● $ docker container run --user 1000:1000 
-v /:/srv -it --rm alpine sh
● / $ id
● uid=1000 gid=1000
● $ rm /srv/*
● rm: can't remove '/srv/*': Permission denied
Run your images
Demo : it will break …
somehow
Conclusion
What have we learned ?
● Use the smallest OS possible
● Don’t expose services on the host
● Open docker API using MTLS only
● optimize build time and image size
What have we learned ?
● Store local credentials using
docker-credential-helpers (gpg)
● Pull images using digest not tag
● Run image unprivileged
● Don't share unless necessary the host
network
What’s next ?
● Docker images signing and scanning
● Linux Capabilities
● Linux Security Modules:
○ SELinux
○ AppArmor
○ Seccomp
● User Namespace
● ...
Questions ?
Rachid
Zarouali
C.I.O Synolia
Docker Captain
Twitter / Slack : @xinity
rzarouali@gmail.com

More Related Content

PDF
Virtual Machines and Docker
PDF
Docker Insight
PPTX
Surveillance on slam technology
PPTX
Docker slides
PDF
Docker-Vancouver Meetup - March 18, 2014 - An Introduction to Docker
PDF
Docker. General overview
PDF
From Docker Run To Docker Compose
PDF
Libcontainer: joining forces under one roof
Virtual Machines and Docker
Docker Insight
Surveillance on slam technology
Docker slides
Docker-Vancouver Meetup - March 18, 2014 - An Introduction to Docker
Docker. General overview
From Docker Run To Docker Compose
Libcontainer: joining forces under one roof

What's hot (20)

PDF
Docker / Ansible
PPTX
Introducing & playing with Docker | Manel Martinez | 1st Docker Crete Meetup
PDF
Introduction to Docker, December 2014 "Tour de France" Edition
PPTX
Academy PRO: Docker. Part 4
PDF
Introduction to docker
PDF
Swarm: Native Docker Clustering
PPTX
Academy PRO: Docker. Part 1
PPTX
Docker session I: Continuous integration, delivery and deployment
PPTX
Docker session II: Introduction to Docker
PDF
From zero to Docker
PDF
Talk on PHP Day Uruguay about Docker
PDF
CoreOS Overview
PPTX
Docker 101
PDF
Docker in everyday development
PDF
Docker presentation
PDF
Puppet Camp Chicago 2014: Docker and Puppet: 1+1=3 (Intermediate)
PPTX
Academy PRO: Docker. Part 2
PPTX
Docker
PDF
Docker Up and Running Introduction
PDF
Linux Containers & Docker
Docker / Ansible
Introducing & playing with Docker | Manel Martinez | 1st Docker Crete Meetup
Introduction to Docker, December 2014 "Tour de France" Edition
Academy PRO: Docker. Part 4
Introduction to docker
Swarm: Native Docker Clustering
Academy PRO: Docker. Part 1
Docker session I: Continuous integration, delivery and deployment
Docker session II: Introduction to Docker
From zero to Docker
Talk on PHP Day Uruguay about Docker
CoreOS Overview
Docker 101
Docker in everyday development
Docker presentation
Puppet Camp Chicago 2014: Docker and Puppet: 1+1=3 (Intermediate)
Academy PRO: Docker. Part 2
Docker
Docker Up and Running Introduction
Linux Containers & Docker
Ad

Similar to Start your container journey safely (20)

PDF
Securité des container
PDF
Docker primer and tips
PDF
Docker presentation
PPTX
Docker 101 : Introduction to Docker and Containers
PDF
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
PDF
Drone presentation
PPTX
Powercoders · Docker · Fall 2021.pptx
PDF
Introduction to Docker and Containers
PDF
Build and run applications in a dockerless kubernetes world
PPTX
Настройка окружения для кросскомпиляции проектов на основе docker'a
PDF
Introduction to Docker and Monitoring with InfluxData
PDF
Testing Docker Images Security
PDF
DOCKER-PIAIC-SLIDES
ODP
Docker on Power Systems
PDF
Containers + Docker workshop - part 2
PDF
DCSF 19 Building Your Development Pipeline
PDF
Integration kubernetes with docker private registry
PDF
Docker Up and Running for Web Developers
PDF
Docker up and Running For Web Developers
PDF
Testing Docker Images Security -All day dev ops 2017
Securité des container
Docker primer and tips
Docker presentation
Docker 101 : Introduction to Docker and Containers
Introduction to Docker at SF Peninsula Software Development Meetup @Guidewire
Drone presentation
Powercoders · Docker · Fall 2021.pptx
Introduction to Docker and Containers
Build and run applications in a dockerless kubernetes world
Настройка окружения для кросскомпиляции проектов на основе docker'a
Introduction to Docker and Monitoring with InfluxData
Testing Docker Images Security
DOCKER-PIAIC-SLIDES
Docker on Power Systems
Containers + Docker workshop - part 2
DCSF 19 Building Your Development Pipeline
Integration kubernetes with docker private registry
Docker Up and Running for Web Developers
Docker up and Running For Web Developers
Testing Docker Images Security -All day dev ops 2017
Ad

More from Rachid Zarouali (9)

PPTX
devopsrex 2024 (Rachid Zarouali): ca passe ou ca kaas ?
PPTX
Les containers docker vu par un chef cuisinier et un mécanicien
PPTX
Containers explained as for cook and a mecanics
PPTX
Devops rex tales of container security
PPTX
Kit de Developpement Synolia
PDF
Docker to the Rescue of an Ops Team
PDF
ContainerDays Hamburg 2017: Deploy Resilient E-Commerce Platform
PDF
Percona: Integrate PMM within an existing monitoring platform
PDF
Meetup afup 21/09/16: monitoring à SYNOLIA
devopsrex 2024 (Rachid Zarouali): ca passe ou ca kaas ?
Les containers docker vu par un chef cuisinier et un mécanicien
Containers explained as for cook and a mecanics
Devops rex tales of container security
Kit de Developpement Synolia
Docker to the Rescue of an Ops Team
ContainerDays Hamburg 2017: Deploy Resilient E-Commerce Platform
Percona: Integrate PMM within an existing monitoring platform
Meetup afup 21/09/16: monitoring à SYNOLIA

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPT
Teaching material agriculture food technology
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
cuic standard and advanced reporting.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Getting Started with Data Integration: FME Form 101
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
A Presentation on Artificial Intelligence
PDF
Electronic commerce courselecture one. Pdf
Encapsulation_ Review paper, used for researhc scholars
Network Security Unit 5.pdf for BCA BBA.
NewMind AI Weekly Chronicles - August'25-Week II
Teaching material agriculture food technology
Dropbox Q2 2025 Financial Results & Investor Presentation
SOPHOS-XG Firewall Administrator PPT.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Mobile App Security Testing_ A Comprehensive Guide.pdf
Machine learning based COVID-19 study performance prediction
Reach Out and Touch Someone: Haptics and Empathic Computing
cuic standard and advanced reporting.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Programs and apps: productivity, graphics, security and other tools
Getting Started with Data Integration: FME Form 101
Advanced methodologies resolving dimensionality complications for autism neur...
A Presentation on Artificial Intelligence
Electronic commerce courselecture one. Pdf

Start your container journey safely

  • 2. Rachid Zarouali C.I.O Synolia Docker Captain Twitter / Slack : @xinity rzarouali@gmail.com
  • 3. ● Hosts Security ● ● Image Management ● ● Container Security ● ● Opensource Tools Agenda
  • 5. ● security is : ○ Everyone's responsibility ○ Necessary ○ Is not hard ○ A never ending story ○ ● But we are lazy when it’s come to it !!!! ○ Who, Why, How, When
  • 8. ● docker run -d -v /:/srv …… ● ● docker run -d --cap-add=ALL …. (*) ● ● docker run -d --privileged …. (*): https://docs.docker.com/engine/reference/run/#runtime-privilege-a nd-linux-capabilities (bad) habits I
  • 9. ● docker exec -ti myapache bash ○ apt install mysql-server ○ ● docker exec -ti mycontainer bash ○ apt full-upgrade ● (bad) habits II
  • 10. Security Topics Docker Security Features : ○ Image building and Signing ○ Security Scanning ○ Docker Content Trust ○ Linux Security Features : ○ Kernel Capabilities ○ Seccomp ○ AppArmor
  • 11. Back to basics Anatomy of a container
  • 12. Anatomy of a container User Space: ● Binaries ● Libraries ● Dependencies Kernel Space: ● Process tree ● Filesystem root ● Network ● Limits on resource
  • 13. Anatomy of a container Namespaces: ● The PID namespace stops processes in one container from seeing processes in another container (or on the host) ● The User namespace allows containers to run processes as root inside the container but as non-privileged users outside the container (on the host) Cgroups: ● Can limit the amount of CPU or memory a container can use, and prevent them from consuming all system resource
  • 14. Anatomy of a container Namespaces Cgroup Cgroup root directory IPC System V IPC, POSIX message queues Network Network devices, stacks, ports, etc. Mount Mount points PID Process IDs User User and group IDs (disabled by default) UTS Hostname and NIS domain name Cgroups Memory CPU Blkio Cpuacct Cpuset Devices Net_prio Freezer
  • 16. Docker hosts ● Different implementations ○ AtomicOS ○ CoreOS ○ RancherOS ○ LinuxKit ….
  • 17. Docker hosts ● AtomicOS ○ Striped down fedora with docker ○ K8s oriented ○ Full containerOS ○ Integration with Cockpit/Openshift ○ ISO: ~ 900mb
  • 18. Docker hosts ● CoreOS ○ Rkt / Docker support ○ Tricky management ○ Integration with tectonic ○ Acquired by RedHat ○ ISO: ~ 350 mb
  • 20. Docker hosts ● RancherOS ○ Full Docker Based ○ Multiple console / engine ○ Stateless by default ○ Easy to manage ○ Integration with Rancher ○ ISO: 85mb
  • 21. Docker hosts ● LinuxKit ○ Full Docker Based ○ K8s support ○ Highly stripped down ○ Modular build (moby project) ○ System developer oriented ○ ISO: < 30 mb
  • 24. Docker images Image: several read-only layers build from a Dockerfile Container: Image + read-write layer I.e: `docker run -ti debian:stretch-slim bash`
  • 26. Docker images More layers mean : ● larger image ● longer build, push and pull from a registry Small images mean : ● faster build and deploy ● small surface of attack
  • 27. Docker images How to reduce layers number: ● Share base image as much as possible ● Limit data written to the layer (nothing unnecessary) ● Chain RUN statements
  • 28. Docker images FROM ubuntu:latest LABEL maintainer abbyfull@amazon.com RUN apt-get update -y && apt-get install -y python-pip python-dev build-essential COPY . /app WORKDIR /app RUN pip install –r requirements.txt EXPOSE 5000 ENTRYPOINT ["python"] CMD ["application.py"]
  • 29. Docker images FROM python:2.7-alpine LABEL maintainer abbyfull@amazon.com ONBUILD ADD requirements.txt /app ONBUILD RUN pip install –r /app/requirements.txt ONBUILD COPY . /app WORKDIR /app EXPOSE 5000 ENTRYPOINT ["python"] CMD ["application.py"]
  • 30. Docker images Use minimalistic base images ● Smaller images reduce the attack surface ● The official Alpine base image is <5MB Use official images as base images ● All official images are scanned for vulnerabilities ● Usually follow best practices Use MultiStage Build as much as possible /! generate smaller image, but not necessarily faster /!
  • 31. Docker images Pull images by digest ‘Image digests are a hash of the image’s config object ) ● This makes them immutable ● If the contents of the image are changed/tampered with, the digest will be different
  • 32. Docker images Demo: build, pull and more
  • 33. Run your images Dockerd requires root access ● Uses kernel features like namespaces Verify root access of dockerd: $ ps ufaxw | grep dockerd
  • 34. Run your images By default dockerd listens on /var/run/docker.sock ● Non-networked , local Unix socket ● Own by dockerd group ○ $ ls -l /var/run/docker.sock ○ srw-rw---- 1 root docker 0 Mar 30 09:15 /var/run/docker.sock
  • 35. Run your images ● Non root user should be member of docker group /! don’t do `sudo docker ….` /! ○ $ sudo usermod -aG docker xinity ○ $ id xinity
  • 36. Run your images By default containers runs as root /! $ docker container run -v /:/srv -it --rm alpine sh # whoami root # id uid=0(root) gid=0(root) # rm -rf /srv/*
  • 37. Run your images By default root inside == root outside of a container /! run your containers unprivileged /! ● $ docker container run --user 1000:1000 -v /:/srv -it --rm alpine sh ● / $ id ● uid=1000 gid=1000 ● $ rm /srv/* ● rm: can't remove '/srv/*': Permission denied
  • 38. Run your images Demo : it will break … somehow
  • 40. What have we learned ? ● Use the smallest OS possible ● Don’t expose services on the host ● Open docker API using MTLS only ● optimize build time and image size
  • 41. What have we learned ? ● Store local credentials using docker-credential-helpers (gpg) ● Pull images using digest not tag ● Run image unprivileged ● Don't share unless necessary the host network
  • 42. What’s next ? ● Docker images signing and scanning ● Linux Capabilities ● Linux Security Modules: ○ SELinux ○ AppArmor ○ Seccomp ● User Namespace ● ...
  • 44. Rachid Zarouali C.I.O Synolia Docker Captain Twitter / Slack : @xinity rzarouali@gmail.com