Linuxhotel Wiki

Wie ging das nochmal?

Benutzer-Werkzeuge

Webseiten-Werkzeuge


admin_grundlagen:docker:build

erstes Docker Image selbst bauen

Pakete

  • Rocky Linux (9):
    • erst epel-release installieren (fügt neues Repository hinzu)
    • debootstrap
  • Debian (ab 12): debootstrap

Image bauen

1)

sudo debootstrap --variant=minbase trixie ./debian http://debian/debian
sudo tar cC debian/ . | docker image import - ingo/debian:trixie

Tag latest hinzufügen:

docker image ls ingo/debian:trixie

→ id rauskopieren (z.B. dc9f1edde160)

docker image tag dc9f1edde160 ingo/debian:latest

testen

docker container run ingo/debian echo hello world

Dockerfile - Docker Images weiterbauen

mkdir static_web
cd static_web
Dockerfile
FROM ingo/debian:trixie
LABEL version="0.0.1"
LABEL maintainer="me@example.com"
ENV DEBIAN_FRONTEND noninteractive
ENV REFRESHED_AT 2026-01-07
RUN set -eux; \
  apt-get -qq update; \
  apt-get install -y --no-install-recommends nginx
RUN find / -xdev -user root -type f -perm /u+s -exec chmod u-s {} +
RUN echo 'A warm welcome from your Dockerfile' > /var/www/html/index.html
EXPOSE 80
ENTRYPOINT ["/usr/sbin/nginx", "-g", "daemon off;"]
docker build -t='ingo/static_web:0.0.1' .
docker image ls
docker container run -d -p 80:80 --name my_static_web ingo/static_web
curl -s http://localhost:80

ENTRYPOINT / CMD / run-Command

ENTRYPOINT CMD run-Command ausgeführt wird
["script.sh"]
script.sh
["script.sh"]
/bin/dash
script.sh /bin/dash
["script.sh"]
["httpd"]
script.sh httpd
["script.sh"]
["httpd"]
/bin/dash
script.sh /bin/dash
["/bin/sh"]
/bin/sh
["/bin/sh"]
/bin/dash
/bin/dash
/bin/bash

2)

1)
anders als das Image aus https://hub.docker.com/_/debian ist dieses Image nicht reproduzierbar
2)
https://docs.docker.com/reference/dockerfile/#understand-how-cmd-and-entrypoint-interact sagt error, not allowed. Docker Version 20.10.24+dfsg1 hat bash ausgeführt.
admin_grundlagen/docker/build.txt · Zuletzt geändert: 2026/01/25 13:46 von ingo_wichmann