Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
| — |
admin_grundlagen:docker:apache_httpd_mit_docker [2026/01/25 13:48] (aktuell) ingo_wichmann angelegt |
||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| + | ====== Apache httpd von Docker ====== | ||
| + | siehe https://hub.docker.com/_/httpd | ||
| + | |||
| + | ==== Hinweis für Podman ==== | ||
| + | |||
| + | Für podmand ''docker'' durch ''podman'' ersetzen und alle Images ggf. mit ''docker.io/'' prefixen. | ||
| + | |||
| + | ===== persistente Daten für den Container anlegen ===== | ||
| + | mkdir -p /srv/docker/httpd/htdocs | ||
| + | cd /srv/docker/httpd | ||
| + | <code html /srv/docker/httpd/htdocs/index.html> | ||
| + | <html> | ||
| + | <head> | ||
| + | <title>Hello World!</title> | ||
| + | </head> | ||
| + | <body> | ||
| + | Hello World | ||
| + | </body> | ||
| + | </html> | ||
| + | </code> | ||
| + | ===== erster Start ===== | ||
| + | docker run -d --name hello-httpd -p 8888:80 -v '/srv/docker/httpd/htdocs:/usr/local/apache2/htdocs/' httpd:2.4 | ||
| + | -> http://localhost:8888 | ||
| + | curl http://localhost:8888 | ||
| + | Betreten der Instanz: | ||
| + | docker exec -it hello-httpd /bin/bash | ||
| + | ls conf/httpd.conf | ||
| + | exit | ||
| + | Instanz löschen: | ||
| + | docker stop hello-httpd | ||
| + | docker rm hello-httpd | ||
| + | |||
| + | ===== Start mit eigener Konfigurationsdatei ===== | ||
| + | ==== manuell ==== | ||
| + | Extrahieren der Konfigurationsdatei: | ||
| + | cd /srv/docker/httpd | ||
| + | docker run --rm httpd:2.4 cat /usr/local/apache2/conf/httpd.conf > httpd.conf | ||
| + | Konfigurationsdatei bearbeiten: | ||
| + | sed -i.bak 's/^Listen 80/Listen 8001/' httpd.conf | ||
| + | diff httpd.conf{,.bak} | ||
| + | Starten: | ||
| + | docker run -d --name httpd_8001 -p 8888:8001 -v '/srv/docker/httpd/htdocs:/usr/local/apache2/htdocs/' -v '/srv/docker/httpd/httpd.conf:/usr/local/apache2/conf/httpd.conf' httpd:2.4 | ||
| + | -> http://localhost:8888 | ||
| + | |||
| + | Löschen: | ||
| + | docker stop httpd_8001 | ||
| + | docker rm httpd_8001 | ||
| + | ==== mit Dockerfile ==== | ||
| + | TODO: | ||
| + | <code Dockerfile Dockerfile> | ||
| + | FROM httpd:2.4 | ||
| + | CMD sed -i 's/^Listen 80/Listen 8001/' /usr/local/apache2/conf/httpd.conf | ||
| + | </code> | ||