admin_grundlagen:docker:build
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
| Beide Seiten, vorherige ÜberarbeitungVorherige ÜberarbeitungNächste Überarbeitung | Vorherige Überarbeitung | ||
| admin_grundlagen:docker:build [2026/05/30 17:25] – [Docker Image aktualisieren] peter_rossbach2 | admin_grundlagen:docker:build [2026/10/09 20:58] (aktuell) – ingo_wichmann | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | ====== | + | ====== Docker Image selbst bauen ====== |
| ===== Pakete ===== | ===== Pakete ===== | ||
| === Rocky Linux (10): === | === Rocky Linux (10): === | ||
| Zeile 8: | Zeile 8: | ||
| apt install -y debootstrap | apt install -y debootstrap | ||
| - | ===== Image bauen ===== | + | ===== Image aus tar-Archiv |
| (( anders als das Image aus https:// | (( anders als das Image aus https:// | ||
| + | sudo debootstrap --variant=minbase trixie ./debian http:// | ||
| + | (( im Linuxhotel-Netzwerk lokalen Spiegelserver benutzen: | ||
| sudo debootstrap --variant=minbase trixie ./debian http:// | sudo debootstrap --variant=minbase trixie ./debian http:// | ||
| + | )) | ||
| (( unter RockyLinux '' | (( unter RockyLinux '' | ||
| sudo debootstrap --variant=minbase --keyring=/ | sudo debootstrap --variant=minbase --keyring=/ | ||
| Zeile 21: | Zeile 24: | ||
| ==== testen ==== | ==== testen ==== | ||
| - | docker container run ingo/ | + | docker container run --rm ingo/ |
| - | -> '' | + | -> Ausgabe von '' |
| - | ====== Dockerfile - Docker Images weiterbauen ====== | + | |
| - | mkdir nginx | + | |
| - | cd nginx | + | |
| - | ++++ podman | | + | |
| - | bei Podman darf die Datei auch '' | + | |
| - | ++++ | + | |
| - | <file txt Dockerfile> | + | |
| - | FROM ingo/ | + | |
| - | ENV DEBIAN_FRONTEND=noninteractive | + | (( Wenn nicht: |
| - | RUN set -eux; \ | + | |
| - | | + | -> Nameserver kommt von Docker, nicht aus dem Image |
| - | apt-get install -y --no-install-recommends nginx | + | |
| - | RUN echo 'A warm welcome from your Dockerfile' | + | |
| - | EXPOSE 80 | + | |
| - | ENTRYPOINT ["/ | + | |
| - | ARG REFRESHED_AT=2026-01-07 | + | Ändern |
| - | LABEL version=" | + | docker container run --rm --dns 192.168.1.5 ingo/ |
| - | LABEL maintainer=" | + | docker |
| - | LABEL org.opencontainers.image.authors=" | + | )) |
| - | LABEL org.opencontainers.image.created=$REFRESHED_AT | + | |
| - | </ | + | |
| - | ++++ ENTRYPOINT / CMD / run-Command | | + | |
| - | ^ '' | + | |
| - | |< | + | |
| - | |< | + | |
| - | |< | + | |
| - | |< | + | |
| - | | | < | + | |
| - | | | < | + | |
| - | | | | | < | + | |
| - | ++++ | + | |
| - | Image mit den Erweiterungen aus dem '' | + | |
| - | docker build -t=' | + | |
| - | Image anzeigen: | + | |
| - | docker image ls ingo/ | + | |
| - | -> id rauskopieren (z.B. '' | + | |
| - | Image taggen: | + | |
| - | docker image tag 5879d7773761 ingo/ | + | |
| - | Container starten: | + | |
| - | docker container run -d -p 80:80 --name my_nginx ingo/ | + | |
| - | Zugriff auf nginx testen: | + | |
| - | curl -s http:// | + | |
| - | -> im Browser http:// | + | |
| - | + | ||
| - | ====== Docker Image aktualisieren ====== | + | |
| - | <file txt Dockerfile> | + | |
| - | … | + | |
| - | RUN ln -sf /dev/stdout / | + | |
| - | && ln -sf /dev/stderr / | + | |
| - | … | + | |
| - | </ | + | |
| - | + | ||
| - | docker build --no-cache --pull -t=' | + | |
| - | + | ||
| - | ++++ podman | | + | |
| - | podman build --no-cache -t=' | + | |
| - | -> allerdings werden dann alle 12 STEPs neu gebaut. | + | |
| - | + | ||
| - | TODO: liegt das an dem fehlenden --pull? | + | |
| - | AI Slop Vermutung: | + | |
| - | Docker built your image without errors because it keeps un-namespaced local images as-is. In contrast, Podman automatically prefixes locally built or untagged registry images with localhost/ to prevent collisions with official registries. | + | |
| - | When you use the --pull flag, Podman is forced to try downloading a fresh version of that base image from an external source. Because it sees localhost/ | + | |
| - | + | ||
| - | Unter Debian mit Docker version 26.1.5+dfsg1, build a72d7cd klappt '' | + | |
| - | ERROR: failed to solve: | + | |
| - | ++++ | + | |
| - | + | ||
| - | Jetzt noch mal Container starten und | + | |
| - | docker logs | + | |
| - | ansehen. | + | |
| - | + | ||
| - | Bauen mit einem Release Zeitstempel: | + | |
| - | + | ||
| - | <code shell> | + | |
| - | REFRESHED_AT=$(date ' | + | |
| - | docker build --no-cache --pull \ | + | |
| - | | + | |
| - | -t=' | + | |
| - | -t=ingo/ | + | |
| - | </ | + | |
| - | + | ||
| - | + | ||
| - | Nginx as Systemd: | + | |
| - | + | ||
| - | <code bash> | + | |
| - | mkdir ~/ | + | |
| - | cat > | + | |
| - | FROM registry.access.redhat.com/ | + | |
| - | RUN dnf -y install nginx \ | + | |
| - | && | + | |
| - | && | + | |
| - | STOPSIGNAL SIGRTMIN+3 | + | |
| - | CMD ["/ | + | |
| - | EOF | + | |
| - | + | ||
| - | docker build -t ubi9-nginx-systemd: | + | |
| - | docker run --name ubi9-nginx -d -p 8090:80 ubi9-nginx-systemd: | + | |
| - | docker exec -it ubi9-nginx systemctl status | + | |
| - | docker exec -it ubi9-nginx journalctl -u nginx | + | |
| - | # ups.. | + | |
| - | docker logs ubi9-nginx | + | |
| - | </code> | + | |
| - | + | ||
| - | <code bash> | + | |
| - | # build with compose | + | |
| - | cat > | + | |
| - | services: | + | |
| - | | + | |
| - | build: . | + | |
| - | ports: | + | |
| - | - " | + | |
| - | tmpfs: | + | |
| - | - /run | + | |
| - | - /run/lock | + | |
| - | - /tmp | + | |
| - | stop_signal: | + | |
| - | EOF | + | |
| - | docker compose build | + | |
| - | docker compose up -d | + | |
| - | docker compose exec nginx ps -ef | + | |
| - | docker compose down | + | |
| - | </ | + | |
| - | + | ||
| - | ++++ this doesn' | + | |
| - | + | ||
| - | <code bash> | + | |
| - | + | ||
| - | cat > | + | |
| - | FROM registry.access.redhat.com/ | + | |
| - | RUN dnf -y install nginx \ | + | |
| - | && | + | |
| - | + | ||
| - | # nginx logs to files (important for tail) | + | |
| - | RUN mkdir -p / | + | |
| - | + | ||
| - | # systemd override for nginx | + | |
| - | RUN mkdir -p / | + | |
| - | cat <<' | + | |
| - | [Service] | + | |
| - | StandardOutput=journal | + | |
| - | StandardError=journal | + | |
| - | EOF | + | |
| - | + | ||
| - | # log forwarder service | + | |
| - | RUN cat <<' | + | |
| - | [Unit] | + | |
| - | Description=Nginx log forwarder | + | |
| - | After=nginx.service | + | |
| - | Requires=nginx.service | + | |
| - | [Service] | + | |
| - | Type=simple | + | |
| - | ExecStart=/ | + | |
| - | Restart=always | + | |
| - | [Install] | + | |
| - | WantedBy=multi-user.target | + | |
| - | EOF | + | |
| - | + | ||
| - | RUN systemctl enable nginx \ | + | |
| - | && | + | |
| - | STOPSIGNAL SIGRTMIN+3 | + | |
| - | CMD ["/ | + | |
| - | EOF | + | |
| - | podman compose build | + | |
| - | podman compose up -d | + | |
| - | curl 127.0.0.1: | + | |
| - | podman compose exec nginx systemctl status nginx-log-forwarder | + | |
| - | podman compose exec nginx journalctl -u nginx-log-forwarder | + | |
| - | # see access logs | + | |
| - | podman logs nginx_nginx_1 | + | |
| - | # no logging output! | + | |
| - | </ | + | |
| - | + | ||
| - | ++++ | + | |
admin_grundlagen/docker/build.1780161903.txt.gz · Zuletzt geändert: 2026/05/30 17:25 von peter_rossbach2
