====== Persistenz mit Volumes ======
Beispiel: Kartenansicht für GPX Track Dateien
git installieren:
apt install -y git
++++ RockyLinux |
dnf install -y git
++++
Quellcode laden:
git clone https://github.com/RalfNieuwenhuizen/routes-explorer.git
cd routes-explorer/
Dockerfile: Version hinzufügen
…
LABEL version="0.0.1"
Image bauen:
docker build -t='ingo/routes-explorer:0.0.1' .
===== CLI =====
==== ohne Volume ====
Container starten:
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/
http://localhost:5000
-> GPX-Dateien hochladen
Container updaten:
…
LABEL version="0.0.2"
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 ====