layout: false template: inverse class: center, middle
template: inverse
layout: false
.large[
.left[Haikel (@hguemar).............. ]
.left[Mario (@mariolet)................ ]
.left[Mike (@mjbright)................. ]
]
template: inverse
layout: false
.tc-left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
Copy Sources
Mount Sources
Dockerize Your Tools
ONBUILD Image
Dependencies First Dockerfile
]
.tc-center-column[
Build From Scratch
Containers Launcher
]
.tc-right-column[
Mount Sources
Docker Socket Mount
Containers Launcher
Build From Scratch
Host Spoofing
ENTRYPOINT and CMD combined
Exec Form ENTRYPOINT
]
template: inverse
A development pattern
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
- development pattern
- Sources are copied inside the image
- Simplest development pattern
- A new image should be built for every code change
- Build tools are included in the image
- Usually a different image is used to run the application ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
Docker Image
2048
Source code
https://github/l0rd/containerspatterns/CS/
Build and run commands
docker build -t 2048 .
docker run -d -p 8080:80 2048
]
??? In this pattern it's particularly important to separate in 2 distinct steps:
- fetching the dependencies
- build of the application
template: inverse
A development and runtime pattern
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
- Development and Runtime Pattern
- Source folder is bind mounted when running the container
- Pattern particularly suited for dynamic languages
- Not recommended for production
- No need to rebuild or restart container when sources are updated
- Build tools are included in the image
- The same image can be used to compile and run the application ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
Docker Image
2048
Source code
https://github/l0rd/containerspatterns/MS/
Build and run command
docker build -t 2048 .
docker run -p 8080:80 \
-v $(pwd):/usr/local/apache2/htdocs/ \
2048
]
template: inverse
A development pattern
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
- Development pattern
- A tool is packaged and distributed as a Docker image
- Allow to run multiple versions of the same tool
- The tool version and installation is described in a Dockerfile
- Files can be shared between the container and the host with volumes
alias
command can be used to make it easier to run ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
Docker Image
maven:3.3.3-jdk-8
Source code
https://github/l0rd/containerspatterns/DYT
Run command
# Make the alias of the dockerized tool
alias mvn="docker run \
-v $(pwd):/usr/src \
-v ~/.m2:/root/.m2 \
-w /usr/src \
maven:3.3.3-jdk-8 \
mvn"
# Run the tool
mvn -version
]
template: inverse
A runtime pattern
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
- Runtime Pattern
- The Docker socket is bind mounted when the container is started
- Allow to manage containers from another container
- Usages:
- Container monitoring tools
- CI/CD tools
- Containers launchers ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
Docker Image
containerslanguages/golang
Source code
https://github/l0rd/containerspatterns/DSM
Run command
docker run -v /var/run/docker.sock:/var/run/docker.sock \
containerslanguages/golang
]
template: inverse
A Distribution and runtime pattern
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
- Runtime Pattern
- The Docker socket is bind mounted when the container is started
- Use to compose multiple containers without Docker compose or similar ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
Docker Image
containerslanguages/rust-launcher
Source code
https://github/l0rd/containerspatterns/CL
Run command
docker run -v $(pwd):/src/ \
-v /var/run/docker.sock:/var/run/docker.sock \
containerslanguages/rust-launcher
]
template: inverse
A Distribution and runtime pattern
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
- Distribution and Runtime Pattern
- The base image is the smallest possible:
Scratch
- Use to make ridiculously small images
- Works well with statically linked applications (Go, Rust, C etc...) ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
Docker Image
emilevauge/tictac
Source code
https://github/emilevauge/tictac/
Run command
docker build -t tictac .
# Compare tictac binary size with tictac docker image size
]
template: inverse
A runtime pattern
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
- Runtime Pattern
- Run commands inside a container to inspect or alter the Docker host
- Access to host network, filesystem, processes, users etc...
- Break container isolation
- Won't work when security hardening the Docker install ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
Docker Image
alpine
Source code
https://github/l0rd/containerspatterns/HS
Run command
docker run --net=host \
-v /:/hostfs/ \
--pid=host \
--uts=host \
--ipc=host \
-v $(pwd):/src/ \
alpine sh -c ". /src/print_host_info.sh"
]
template: inverse
A runtime pattern
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
- Runtime Pattern
- Instructions ENTRYPOINT and CMD are used together
- ENTRYPOINT is the fixed part of the command
- CMD is the variable part (usually the parameters) ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
Docker Image
ecc
Source code
https://github/l0rd/containerspatterns/ECC
Run command
docker run -ti --rm ecc
docker run -ti --rm ecc -f lean docker
]
template: inverse
A runtime pattern
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
- Runtime Pattern
- JSON is used to define the command and its parameters
- It's the alternative to the Shell Form (
/bin/sh -c
on Linux orcmd /S /C
on Windows) - No varialbe substitution and the command is PID 1
- Unix signals are notified directly to the program (not the shell) ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
Docker Image
httpd
Source code
https://github/l0rd/containerspatterns/EFE/
Build and Run commands
docker build -t httpd-exec -f Dockerfile.exec .
docker build -t httpd-shell -f Dockerfile.shell .
docker run -i -P --rm httpd-exec
# Stop it using ^C
docker run -i -P --rm httpd-shell
# (Try to) stop it using ^C
]
template: inverse
A development pattern
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
- Development pattern
- Build behaviour inherited from base image
- Avoid duplicate code in Dockerfiles
- Can make Dockerfile difficult to read ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
Docker Image
obi-java
Source code
https://github/l0rd/containerspatterns/OBI
Build/Run commands
docker build -t obi-java .
docker run --rm obi-java
]
template: inverse
A development pattern
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
- Development pattern
- Dependencies should not be fetched at every change in source code
- In Dockerfile dependency list should be copied before source code ]
.left-column[ .footnote[@hguemar, @mariolet, @mjbright ]
] .right-column[
Docker Image dfd
Source code
https://github/l0rd/containerspatterns/dfd
https://github/polyfunc/flask-todolist
Build command
docker build -t dfd .
docker build -t dfd-orig -f Dockerfile.orig .
touch onefile
docker build -t dfd .
docker build -t dfd-orig -f Dockerfile.orig .
]
template: inverse
class: center .footnote[@hguemar, @mariolet, @mjbright ]
template: inverse
https://l0rd.github.io/containerspatterns
[@hguemar, @mariolet, @mjbright]