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 nginx
cd nginx
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/nginx:0.0.1' .
docker image ls ingo/nginx:0.0.1

→ id rauskopieren (z.B. 5879d7773761)

docker image tag 5879d7773761 ingo/nginx:latest
docker container run -d -p 80:80 --name my_nginx ingo/nginx
curl -s http://localhost:80

→ im Browser http://localhost öffnen

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/02/22 13:42 von ingo_wichmann