English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Suche Docker Hub Der httpd-Image auf:
Durch Sortieren nach können andere Versionen von httpd angezeigt werden, standardmäßig die neueste Version httpd:latest.
Außerdem können wir den Befehl docker search httpd verwenden, um verfügbare Versionen anzuzeigen:
w3codebox@w3codebox:~/apache$ docker search httpd NAME Beschreibung STARS OFFIZIELL AUTOMATISIERT httpd Der Apache HTTP Server... 524 [OK] centos/httpd 7 [OK] rgielen/httpd-image-php5 Docker-Image für Apache... 1 [OK] microwebapps/httpd-frontend Httpd frontend allowing... 1 [OK] lolhens/httpd Apache httpd 2 Server 1 [OK] publici/httpd httpd:latest publicisworldwide/httpd Der Apache httpd Webserver... rgielen/httpd-image-einfache Docker-Image für einfache... solsson/httpd Derivatives of the offi... 0 [OK] rgielen/httpd-image-drush Apache HTTPD + Drupal S... 0 [OK] learninglayers/httpd 0 [OK] sohrabkhan/httpd Docker httpd + php5.6 (... 0 [OK] aintohvri/docker-httpd Apache HTTPD Docker ext... 0 [OK] alizarion/httpd httpd on centos with mo... 0 [OK] ...
Here we pull the official image
w3codebox@w3codebox:~/apache$ docker pull httpd
After the download is complete, we can find the image with REPOSITORY as httpd in the local image list.
w3codebox@w3codebox:~/apache$ docker images httpd REPOSITORY TAG IMAGE ID ERSTELLT GRÖSSE httpd latest da1536b4ef14 23 vor Sekunden 195.1 MB
Create Dockerfile
Firstly, create the directory apache to store the related items later.
w3codebox@w3codebox:~$ mkdir -p ~/apache/www ~/apache/logs ~/apache/conf
The www directory will be mapped to the application directory configured by the apache container.
The logs directory will be mapped to the log directory of the apache container.
The configuration files in the conf directory will be mapped to the configuration files of the apache container.
Enter the created apache directory and create a Dockerfile.
FROM debian:jessie # add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added #RUN groupadd -r www-data && useradd -r --create-home -g www-data www-data ENV HTTPD_PREFIX /usr/local/apache2 ENV PATH $PATH:$HTTPD_PREFIX/bin RUN mkdir -p "$HTTPD_PREFIX" \ && chown www-data:www-data "$HTTPD_PREFIX" WORKDIR $HTTPD_PREFIX # install httpd runtime dependencies # see https://httpd.apache.org/docs/2.4/install.html#requirements RUN apt-get update \ && apt-get install -y --no-install-recommends \ libapr1 \ libaprutil1 \ libaprutil1-ldap \ libapr1-dev \ libaprutil1-dev \ libpcre++0 \ libssl1.0.0 \ && rm -r /var/lib/apt/lists/* ENV HTTPD_VERSION 2.4.20 ENV HTTPD_BZ2_URL https://www.apache.org/dist/httpd/httpd-$HTTPD_VERSION.tar.bz2 RUN buildDeps=' \ ca-certificates \ curl \ bzip2 \ gcc \ libpcre++-dev \ libssl-dev \ make \ ' \ set -x \ && apt-get update \ && apt-get install -y --no-install-recommends $buildDeps \ && rm -r /var/lib/apt/lists/* \ \ && curl -fSL "$HTTPD_BZ2_URL" -o httpd.tar.bz2 \ && curl -fSL "$HTTPD_BZ2_URL.asc" -o httpd.tar.bz2.asc \ # see https://httpd.apache.org/download.cgi#verify && export GNUPGHOME="$(mktemp -d)" \ && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys A93D62ECC3C8EA12DB220EC934EA76E6791485A8 \ && gpg --batch --verify httpd.tar.bz2.asc httpd.tar.bz2 \ && rm -r "$GNUPGHOME" httpd.tar.bz2.asc \ \ && mkdir -p src \ && tar -xvf httpd.tar.bz2 -C src --strip-components=1 \ && rm httpd.tar.bz2 \ && cd src \ \ && ./configure \ --prefix="$HTTPD_PREFIX" \ --enable-mods-shared=reallyall \ && make -j"$(nproc)" \ && make install \ \ && cd .. \ && rm -r src \ \ && sed -ri \ -e 's!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g' \ -e 's!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g' \ "$HTTPD_PREFIX/conf/httpd.conf" \ \ && apt-get purge -y --auto-remove $buildDeps COPY httpd-foreground /usr/local/bin/ EXPOSE 80 CMD ["httpd-foreground"]
Dockerfile-Datei, indem Sie httpd kopieren-foreground /usr/local/bin/ ist der aktuelle Ordner-Kopieren Sie foreground in das Image, als Startskript für den httpd-Dienst, daher müssen wir eine Skriptdatei httpd auf dem lokalen System erstellen-foreground
#!/bin/bash set -e # Apache wird wütend über PID-Dateien, die vor-existing rm -f /usr/local/apache2/logs/httpd.pid exec httpd -DFOREGROUND
Gewähren Sie httpd-Foreground-Datei mit ausführbaren Berechtigungen.
w3codebox@w3codebox:~/apache$ chmod +x httpd-foreground
Erstellen Sie ein Image durch einen Dockerfile, ersetzen Sie es durch Ihren eigenen Namen.
w3codebox@w3codebox:~/apache$ docker build -t httpd .
Nachdem der Prozess abgeschlossen ist, können wir das soeben erstellte Image in der lokalen Image-Liste finden.
w3codebox@w3codebox:~/apache$ docker images httpd REPOSITORY TAG IMAGE ID ERSTELLT GRÖSSE httpd latest da1536b4ef14 23 vor Sekunden 195.1 MB
docker run -p 80:80 -v $PWD/www/:/usr/local/apache2/htdocs/ -v $PWD/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf -v $PWD/logs/:/usr/local/apache2/logs/ -d httpd
Befehlsbeschreibung:
-p 80:80: Mounte den Port des Containers 80 Port wird auf den Host gemappt: 80 Port.
-v $PWD/www/:/usr/local/apache2/htdocs/: Mounte den www-Ordner des Hosts in den Container: /usr/local/apache2/htdocs/.
-v $PWD/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf: Mounte den conf-Ordner des Hosts in den Container:/Montiere die httpd.conf-Datei des Hosts in den Container: /usr/local/apache2/conf/httpd.conf.
-v $PWD/logs/:/usr/local/apache2/logs/: Mounte den logs-Ordner des Hosts in den Container: /usr/local/apache2/logs/.
Container-Startstatus anzeigen:
w3codebox@w3codebox:~/apache$ docker ps CONTAINER ID IMAGE COMMAND ... PORTS ... NAMES 79a97f2aac37 httpd "httpd-foreground" ... 0.0.0.0:80->80/tcp sharp_swanson
Über den Browser besuchen
Es funktioniert! https://de.oldtoolbag.com