Linuxhotel Wiki

Wie ging das nochmal?

Benutzer-Werkzeuge

Webseiten-Werkzeuge


admin_grundlagen:docker:volumes

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen gezeigt.

Link zu der Vergleichsansicht

Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung
Nächste Überarbeitung
Vorherige Überarbeitung
admin_grundlagen:docker:volumes [2026/05/30 22:25]
ingo_wichmann [relativer Pfad]
admin_grundlagen:docker:volumes [2026/05/31 12:34] (aktuell)
ingo_wichmann
Zeile 3: Zeile 3:
  
 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/​   cd routes-explorer/​
- 
 Dockerfile: Version hinzufügen Dockerfile: Version hinzufügen
 <file txt Dockerfile>​ <file txt Dockerfile>​
Zeile 16: Zeile 17:
  
 Image bauen: Image bauen:
-  ​podman ​build -t='​ingo/​routes-explorer:​0.0.1'​ .+  ​docker ​build -t='​ingo/​routes-explorer:​0.0.1'​ .
  
-===== CLI ===== +===== Docker ​CLI ===== 
-==== nicht persistent ​====+==== ohne Volume ​====
 Container starten: Container starten:
-  ​podman ​container run -d -p 5000:​5000 ​-e ROUTES_FOLDER=/​routes ​--name routes-explorer ingo/​routes-explorer:​0.0.1 +  ​docker ​container run -d -p 5000:5000 --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 33: Zeile 33:
 LABEL version="​0.0.2"​ LABEL version="​0.0.2"​
 </​file>​ </​file>​
-  ​podman ​build -t='​ingo/​routes-explorer:​0.0.2'​ . +  ​docker ​build -t='​ingo/​routes-explorer:​0.0.2'​ . 
-  podman container run -d --replace -p 5000:5000 -e ROUTES_FOLDER=/routes --name routes-explorer ingo/​routes-explorer:​0.0.2+++++ Podman | 
 +  podman container run -d --replace -p 5000:5000 --name routes-explorer ingo/routes-explorer:​0.0.2 
 +++++ 
 +  docker container rm -f routes-explorer 
 +  docker container run -d -p 5000:​5000 ​--name routes-explorer ingo/​routes-explorer:​0.0.2
 http://​localhost:​5000 http://​localhost:​5000
 -> GPX-Dateien sind weg -> GPX-Dateien sind weg
  
-==== relativer Pfad ====+==== anonymes Volume ​====
 Container löschen: Container löschen:
-  ​podman ​container rm -f routes-explorer+  ​docker ​container rm -f routes-explorer 
 +Container starten: 
 +  docker container run -d --restart=always -v /routes -p 5000:5000 --name routes-explorer ingo/​routes-explorer:​0.0.1 
 +http://​localhost:​5000 
 +-> GPX-Dateien hochladen 
 +  docker inspect routes-explorer --format json | jq '​.[0].Mounts'​ 
 +-> die hochgeladenen GPX-Dateien liegen in "​Source"​
  
 +Container updaten:
 +++++ Podman |
 +  podman container run -d --restart=always -v /routes -p 5000:5000 --name routes-explorer ingo/​routes-explorer:​0.0.2
 +++++
 +  docker container rm -f routes-explorer
 +  docker container run -d --restart=always -v /routes -p 5000:5000 --name routes-explorer ingo/​routes-explorer:​0.0.2
 +http://​localhost:​5000
 +-> GPX-Dateien sind nicht sichtbar: sie liegen noch in dem alten anonymen Volume.
 +  docker volume ls
 +==== relativer Pfad ====
 +Container löschen:
 +  docker container rm -f routes-explorer
 Daten im Verzeichnis ''​routes''​ speichern: Daten im Verzeichnis ''​routes''​ speichern:
   mkdir routes   mkdir routes
-  ​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+++++ Podman mit SELinux | 
 +  ​podman container run -d --restart=always -v ./​routes:/​routes:​Z -p 5000:5000 --name routes-explorer ingo/​routes-explorer:​0.0.1 
 +++++ 
 +  docker container run -d --restart=always -v ./routes:/​routes ​-p 5000:​5000 ​--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 --name routes-explorer ingo/​routes-explorer:​0.0.2
 +++++
 +  docker container rm -f routes-explorer
 +  docker container run -d --restart=always -v ./​routes:/​routes -p 5000:5000 --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 ====
 +Container löschen:
 +  docker container rm -f routes-explorer
 +Daten im Volume ''​routes''​ speichern:
 +  docker volume create routes
 +  docker container run -d --restart=always -v routes:/​routes -p 5000:5000 --name routes-explorer ingo/​routes-explorer:​0.0.1
 +http://​localhost:​5000
 +-> GPX-Dateien hochladen
 +++++ Podman |
 +  podman volume mount routes
 +++++
 +  docker inspect routes-explorer --format json | jq '​.[0].Mounts.[0].Source'​
 +-> die hochgeladenen GPX-Dateien liegen in diesem Verzeichnis
 +
 +Container updaten:
 +++++ Podman |
 +  podman container run -d --replace --restart=always -v routes:/​routes -p 5000:5000 --name routes-explorer ingo/​routes-explorer:​0.0.2
 +++++
 +  docker container rm -f routes-explorer
 +  docker container run -d --restart=always -v routes:/​routes -p 5000:5000 --name routes-explorer ingo/​routes-explorer:​0.0.2
 +http://​localhost:​5000
 +-> GPX-Dateien sind noch da
 +===== Docker Compose =====
 +Docker CLI Container löschen:
 +  docker container rm -f routes-explorer
 +Compose Verzeichnis anlegen:
 +  mkdir -p /​srv/​docker/​routes-explorer
 +  cd /​srv/​docker/​routes-explorer
 +==== ohne Volume ====
 +<file yaml docker-compose.yml>​
 +services:
 +  routes-explorer:​
 +    image: ingo/​routes-explorer:​0.0.1
 +    ports:
 +      - "​5000:​5000"​
 +</​file>​
 +Container starten:
 +  docker compose up -d
 +http://​localhost:​5000
 +-> GPX-Dateien hochladen
 +
 +Container updaten:
 +<file yaml docker-compose.yml>​
 +
 +    image: ingo/​routes-explorer:​0.0.2
 +
 +</​file>​
 +  docker compose up -d
 +http://​localhost:​5000
 +-> GPX-Dateien sind weg
 +==== anonymes Volume ====
 +Container löschen:
 +  docker compose down
 +Container starten:
 +<file yaml docker-compose.yml>​
 +
 +    image: ingo/​routes-explorer:​0.0.1
 +    volumes:
 +      - /routes
 +</​file>​
 +
 +Container starten:
 +  docker compose up -d
 +http://​localhost:​5000
 +-> GPX-Dateien hochladen
 +++++ Podman |
 +  podman inspect routes-explorer_routes-explorer_1 --format json | jq '​.[0].Mounts'​
 +++++
 +  docker inspect routes-explorer-routes-explorer-1 --format json | jq '​.[0].Mounts'​
 +-> die hochgeladenen GPX-Dateien liegen in "​Source"​
 +
 +Container updaten:
 +<file yaml docker-compose.yml>​
 +
 +    image: ingo/​routes-explorer:​0.0.2
 +
 +</​file>​
 +  docker compose up -d
 +http://​localhost:​5000
 +-> GPX-Dateien sind sind noch da ;-)
 +  docker volume ls
 +==== relativer Pfad ====
 +Container löschen:
 +  docker compose down
 +Daten im Verzeichnis ''​routes''​ speichern:
 +  mkdir routes
 +++++ Podman mit SELinux |
 +<file yaml docker-compose.yml>​
 +
 +    image: ingo/​routes-explorer:​0.0.1
 +    volumes:
 +      - ./​routes:/​routes:​Z
 +</​file>​
 +++++
 +<file yaml docker-compose.yml>​
 +
 +    image: ingo/​routes-explorer:​0.0.1
 +    volumes:
 +      - ./​routes:/​routes
 +    restart: unless-stopped
 +</​file>​
 +Container starten:
 +  docker compose up -d
 http://​localhost:​5000 http://​localhost:​5000
 -> GPX-Dateien hochladen -> GPX-Dateien hochladen
Zeile 53: Zeile 202:
  
 Container updaten: Container updaten:
-  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+<file yaml docker-compose.yml> 
 +… 
 +    image: ingo/​routes-explorer:​0.0.2 
 +… 
 +</​file>​ 
 +  docker compose up -d
 http://​localhost:​5000 http://​localhost:​5000
 -> GPX-Dateien sind noch da -> GPX-Dateien sind noch da
 +++++ Podman |
 +  docker inspect routes-explorer_routes-explorer_1 --format json | jq '​.[0].Mounts'​
 +++++
 +-> relativer Pfad wird von Docker als absoluter Pfad verarbeitet.
 +
 +==== benanntes Volume ====
 +Container löschen:
 +  docker compose down
 +
 +<file yaml docker-compose.yml>​
 +
 +    image: ingo/​routes-explorer:​0.0.1
 +    volumes:
 +      - routes:/​routes
 +    restart: unless-stopped
 +
 +volumes:
 +  routes:
 +</​file>​
 +Container starten:
 +  docker compose up -d
 +http://​localhost:​5000
 +-> GPX-Dateien hochladen
 +++++ Podman |
 +  podman volume mount routes
 +++++
 +  docker inspect routes-explorer-routes-explorer-1 --format json | jq '​.[0].Mounts.[0].Source'​
 +-> die hochgeladenen GPX-Dateien liegen in diesem Verzeichnis
 +
 +Container updaten:
 +<file yaml docker-compose.yml>​
 +
 +    image: ingo/​routes-explorer:​0.0.2
 +
 +</​file>​
 +  docker compose up -d
 +http://​localhost:​5000
 +-> GPX-Dateien sind noch da
 +
 +===== Übersicht =====
 +^                 ^ Docker CLI       ^ compose ^
 +^ ohne Volume ​    | nicht persistent | nicht persistent |
 +^ anonymes Volume | nicht sichtbar ​  | persistent |
 +^ relativer Pfad  | persistent ​      | persistent |
 +^ benantes Volume | persistent ​      | persistent |
  
admin_grundlagen/docker/volumes.1780179930.txt.gz · Zuletzt geändert: 2026/05/30 22:25 von ingo_wichmann