(Usage hints for this presentation)
IT Systems, Summer Term 2024
Dr. Jens Lechtenbörger (License Information)
Containerization = lightweight virtualization
chroot
), copy-on-write, e.g.,
UnionFS:
Images specify execution environments
Dockerfile
as build recipe for image
Reproducibility
E.g. excerpt of
Dockerfile
for TTS that generates audio in this presentation
FROM debian:12.1-slim
RUN apt-get update && apt-get install --no-install-recommends \
curl ffmpeg git-lfs python3-pip python3-venv unzip -y
RUN python3 -m venv /tts
ENV PATH="/tts/bin:$PATH"
RUN pip install wheel
COPY tts/requirements* /tts/
RUN pip install -r /tts/requirements-torch.txt
RUN pip install -r /tts/requirements.txt
...
Image is template for container
Registries publish images
hello-world
docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
[...]
List your images and containers
docker image ls
docker container ls -all
docker container --help
docker container ls --help
Maybe delete image and container
docker rmi -f hello-world
Run web server nginx
docker run -p 8080:80 nginx
-p
: Web server listens on port 80 in container; bind
to port 8080 on host
Visit http://localhost:8080, nginx
server in container
Maybe add option --name my-nginx
: Assign name to container
for subsequent use
docker stop/start/logs/rm my-nginx
-v
in above docker run ...
(before nginx
)
-v /host-directory/with/html-files:/usr/share/nginx/html
/usr/share/nginx/html
is where nginx expects HTML files,
in particular index.html
docker run --name ...
docker start my-nginx
-p
with same port in several docker run
invocations
docker ps
: Note ID or namedocker stop <ID-or-name>
docker run ...
-v
nginx
with option -v
but your files do not appear
docker inspect <name-or-id-of-container>
binds
, telling you what is mapped to
/usr/share/nginx/html
-v C:\Users\...
with Powershell-v C:\\Users/...
with Bash-v /mnt/c/Users/...
with WSL terminalSource files are available on GitLab (check out embedded submodules) under free licenses. Icons of custom controls are by @fontawesome, released under CC BY 4.0.
Except where otherwise noted, the work “Containerization”, © 2019, 2021, 2024 Jens Lechtenbörger, is published under the Creative Commons license CC BY-SA 4.0.