Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
| Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung Nächste Überarbeitung | Vorherige Überarbeitung | ||
|
admin_grundlagen:docker:volumes [2026/05/30 21:53] ingo_wichmann |
admin_grundlagen:docker:volumes [2026/05/30 23:15] (aktuell) ingo_wichmann |
||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| ====== Persistenz mit Volumes ====== | ====== Persistenz mit Volumes ====== | ||
| - | Beispiel: Kartenansicht für GPX Dateien | + | Beispiel: Kartenansicht für GPX Track Dateien |
| git installieren: | git installieren: | ||
| + | apt install -y git | ||
| + | ++++ RockyLinux | | ||
| dnf install -y git | dnf install -y git | ||
| + | ++++ | ||
| Quellcode laden: | Quellcode laden: | ||
| git clone https://github.com/RalfNieuwenhuizen/routes-explorer.git | git clone https://github.com/RalfNieuwenhuizen/routes-explorer.git | ||
| + | cd routes-explorer/ | ||
| Dockerfile: Version hinzufügen | Dockerfile: Version hinzufügen | ||
| Zeile 15: | Zeile 19: | ||
| Image bauen: | Image bauen: | ||
| - | cd routes-explorer/ | + | docker build -t='ingo/routes-explorer:0.0.1' . |
| - | podman build -t='ingo/routes-explorer:0.0.1' . | + | |
| - | ===== nicht persistent ===== | + | ===== CLI ===== |
| + | ==== ohne Volume ==== | ||
| Container starten: | Container starten: | ||
| - | podman container run -d -p 5000:5000 -e ROUTES_FOLDER=/routes --name routes-explorer ingo/routes-explorer | + | docker container run -d -p 5000:5000 -e ROUTES_FOLDER=/routes --name routes-explorer ingo/routes-explorer:0.0.1 |
| GPX-Tracks aussuchen und herunterladen: https://wildnis-wandern.de/gpx-downloads/ | GPX-Tracks aussuchen und herunterladen: https://wildnis-wandern.de/gpx-downloads/ | ||
| Zeile 26: | Zeile 30: | ||
| http://localhost:5000 | http://localhost:5000 | ||
| -> GPX-Dateien hochladen | -> GPX-Dateien hochladen | ||
| + | |||
| + | Container updaten: | ||
| + | <file txt Dockerfile> | ||
| + | … | ||
| + | LABEL version="0.0.2" | ||
| + | </file> | ||
| + | docker build -t='ingo/routes-explorer:0.0.2' . | ||
| + | ++++ Podman | | ||
| + | podman container run -d --replace -p 5000:5000 -e ROUTES_FOLDER=/routes --name routes-explorer ingo/routes-explorer:0.0.2 | ||
| + | ++++ | ||
| + | docker container rm -f routes-explorer | ||
| + | docker container run -d -p 5000:5000 -e ROUTES_FOLDER=/routes --name routes-explorer ingo/routes-explorer:0.0.2 | ||
| + | http://localhost:5000 | ||
| + | -> GPX-Dateien sind weg | ||
| + | |||
| + | ==== anonymes Volume ==== | ||
| + | ==== relativer Pfad ==== | ||
| + | Container löschen: | ||
| + | docker container rm -f routes-explorer | ||
| + | |||
| + | Daten im Verzeichnis ''routes'' speichern: | ||
| + | mkdir routes | ||
| + | ++++ Podman mit SELinux | | ||
| + | podman container run -d --restart=always -v ./routes:/routes:Z -p 5000:5000 -e ROUTES_FOLDER=/routes --name routes-explorer ingo/routes-explorer:0.0.1 | ||
| + | ++++ | ||
| + | docker container run -d --restart=always -v ./routes:/routes: -p 5000:5000 -e ROUTES_FOLDER=/routes --name routes-explorer ingo/routes-explorer:0.0.1 | ||
| + | |||
| + | http://localhost:5000 | ||
| + | -> GPX-Dateien hochladen | ||
| + | |||
| + | ls routes/ | ||
| + | -> zeigt die hochgeladenen GPX-Dateien | ||
| + | |||
| + | Container updaten: | ||
| + | ++++ Podman | | ||
| + | podman container run -d --replace --restart=always -v ./routes:/routes:Z -p 5000:5000 -e ROUTES_FOLDER=/routes --name routes-explorer ingo/routes-explorer:0.0.2 | ||
| + | ++++ | ||
| + | docker container rm -f routes-explorer | ||
| + | docker container run -d --replace --restart=always -v ./routes:/routes: -p 5000:5000 -e ROUTES_FOLDER=/routes --name routes-explorer ingo/routes-explorer:0.0.2 | ||
| + | http://localhost:5000 | ||
| + | -> GPX-Dateien sind noch da | ||
| + | |||
| + | docker inspect routes-explorer --format json | jq '.[0].Mounts' | ||
| + | -> relativer Pfad wird von Docker als absoluter Pfad verarbeitet. | ||
| + | |||
| + | === Sicherheit === | ||
| + | container exec -it routes-explorer bash | ||
| + | cp /usr/bin/cat /routes | ||
| + | chmod u+sx,go+x /routes/cat | ||
| + | ls -l /routes/cat | ||
| + | exit | ||
| + | ls -l ./routes/cat | ||
| + | ==== benanntes Volume ==== | ||