Stellen Sie httpd mit dem Quellcode des Docker-Containers bereit und stellen Sie die Website mit dem Speichervolumen bereit.Erstellen Sie ein httpd-Image// Einen httpd-Container erstellen [root@localhost ~]# docker run -tid --name httpd centos 2d693e16f4f3734b127cbae90d189c1b4e78619a54ceec912a82d96cf4f1c345 [root@localhost ~]# docker ps CONTAINER ID BILD BEFEHL ERSTELLT STATUS PORTS NAMEN 2d693e16f4f3 centos "/bin/bash" vor 5 Sekunden Up 4 Sekunden httpd // Mit diesem Container verbinden [root@localhost ~]# docker exec -it 2d693e16f4f3 /bin/bash [root@2d693e16f4f3 /]# // Legen Sie das Quellpaket in den Container [root@localhost ~]# docker cp /usr/src/apr-1.7.0.tar.gz 2d693e16f4f3:/usr/src/ [root@localhost ~]# docker cp /usr/src/apr-util-1.6.1.tar.gz 2d693e16f4f3:/usr/src/ [root@localhost ~]# docker cp /usr/src/httpd-2.4.49.tar.gz 2d693e16f4f3:/usr/src/ [root@2d693e16f4f3 /]# ls /usr/src/ apr-1.7.0.tar.gz Debug-Kernel apr-util-1.6.1.tar.gz httpd-2.4.49.tar.gz // httpd aus dem Quellcode installieren [root@2d693e16f4f3 /]# useradd -r -M -s /sbin/nologin apache [root@2d693e16f4f3 /]# id apache UID = 998 (Apache) GID = 996 (Apache) Gruppen = 996 (Apache) [root@2d693e16f4f3 /]# yum groups mark install 'Entwicklungstools' -y [root@2d693e16f4f3 /]# yum -y installiere openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make [root@2d693e16f4f3 /]# cd /usr/src/ [root@2d693e16f4f3 src]# tar xf apr-1.7.0.tar.gz -C /usr/local/ [root@2d693e16f4f3 src]# tar xf apr-util-1.6.1.tar.gz -C /usr/local/ [root@2d693e16f4f3 src]# tar xf httpd-2.4.49.tar.gz -C /usr/local/ [root@2d693e16f4f3 src]# cd /usr/local/apr-1.7.0/ [root@2d693e16f4f3 apr-1.7.0]# vi konfigurieren cfgfile="${ofile}T" Falle "$RM \"$cfgfile\"; Ausgang 1" 1 2 15 # $RM "$cfgfile" //Kommentieren Sie diese Zeile oder löschen Sie sie [root@2d693e16f4f3 apr-1.7.0]# ./configure --prefix=/usr/local/apr [root@2d693e16f4f3 apr-1.7.0]# make && make install [root@2d693e16f4f3 lokal]# cd apr-util-1.6.1/ [root@2d693e16f4f3 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ [root@2d693e16f4f3 apr-util-1.6.1]# make && make install [root@2d693e16f4f3 apr-util-1.6.1]# cd ../httpd-2.4.49/ [root@2d693e16f4f3 httpd-2.4.49]# ./configure --prefix=/usr/local/apache \ > --enable-so \ > --enable-ssl \ > --enable-cgi \ > --enable-rewrite \ > --mit-zlib \ > --mit-pcre \ > --with-apr=/usr/local/apr \ > --with-apr-util=/usr/local/apr-util/ \ > --enable-modules=die meisten \ > --enable-mpms-shared=alle \ > --with-mpm=Vorgabe [root@2d693e16f4f3 httpd-2.4.49]# make && make install [root@2d693e16f4f3 lokal]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh [root@2d693e16f4f3 lokal]# Quelle /etc/profile.d/httpd.sh [root@2d693e16f4f3 lokal]# ln -s /usr/local/apache/include /usr/include/apache [root@2d693e16f4f3 lokal]# apachectl start [root@2d693e16f4f3 lokal]# ss -anlt Status Recv-Q Send-Q Lokale Adresse:Port Peer-Adresse:Port Prozess LISTEN 0 128 0.0.0.0:80 0.0.0.0:* [root@2d693e16f4f3 lokal]# cd / [root@2d693e16f4f3 /]# [root@2d693e16f4f3 /]# [root@2d693e16f4f3 /]# vi start.sh #!/bin/sh /usr/local/apache/bin/apachectl start /bin/bash [root@2d693e16f4f3 /]# chmod +x start.sh //Image erstellen [root@localhost ~]# docker commit -p -c 'CMD ["/bin/bash","start.sh"]' 2d693e16f4f3 syblyw0806/httpd:v0.1 sha256:16913ce01fdceee9a389906cf385893120734b1a088b894cc5dce1a9ead252fd [root@localhost ~]# Docker-Bilder REPOSITORY TAG BILD ID ERSTELLT GRÖSSE syblyw0806/httpd v0.1 16913ce01fdc vor 6 Sekunden 713 MB busybox latest d23834f29b38 vor 6 Tagen 1,24 MB centos latest 5d0da3dc9764 vor 2 Monaten 231MB NFS bereitstellenSie müssen eine neue virtuelle Maschine starten [root@localhost ~]# yum -y installiere nfs-utils [root@localhost ~]# systemctl nfs-server.service neu starten [root@localhost ~]# mkdir /nfs [root@localhost ~]# chmod 777 /nfs/ [root@localhost ~]# vim /etc/exports /nfs 192.168.200.136(rw) [root@localhost ~]# systemctl NFS-Server neu starten Installieren Sie NFS auf der virtuellen Maschine mit dem Docker-Dienst [root@localhost ~]# yum -y installiere nfs-utils [root@localhost ~]# showmount -e 192.168.200.137 Exportliste für 192.168.200.137: /nfs 192.168.200.136 Montieren[root@localhost ~]# mount -t nfs 192.168.200.137:/nfs /var/www/html/ [root@localhost ~]# df -h Verwendete Dateisystemgröße Verfügbare Nutzung% Eingebunden auf devtmpfs 883M 0 883M 0 % /Entwickler tmpfs 901M 0 901M 0 % /Entwickler/shm tmpfs 901 Mio. 8,9 Mio. 892 Mio. 1 %/Lauf tmpfs 901 M 0 901 M 0 % /sys/fs/cgroup /dev/mapper/rhel-root 47 G 23 G 25 G 48 % / /dev/nvme0n1p1 1014M 179M 836M 18 % /boot tmpfs 181M 0 181M 0 % /run/Benutzer/0 Overlay 47 G 23 G 25 G 48 % /var/lib/docker/overlay2/0a219b8bbb04290f6b1cc1ae29f5eb1a9bc713ff12c86c86c7e13d5c7ca63a0e/zusammengeführt 192.168.200.137:/nfs 47 G 2,2 G 45 G 5 % /var/www/html Erstellen Sie einen Container und ordnen Sie ihn zu[root@localhost ~]# docker run -itd --name httpd1 -p 80:80 -v /var/www/html/:/usr/local/apache/htdocs 16913ce01fdc 42e38f1db61e49fafa0682125d0425e3d41c4f2db0f48e1973dee1905a90daf3 [root@localhost ~]# docker ps CONTAINER ID BILD BEFEHL ERSTELLT STATUS PORTS NAMEN 42e38f1db61e 16913ce01fdc "/bin/bash start.sh" vor 10 Sekunden Aktiv seit 9 Sekunden 0.0.0.0:80->80/tcp, :::80->80/tcp httpd1 Laden Sie den Code für die Website hoch, die wir bereitstellen möchten [root@localhost ~]# cd /var/www/html/ [root@localhost html]# ls game.html Bilder index.html js-Stil Überprüfen Sie zu diesem Zeitpunkt NFS in einer neu geöffneten virtuellen Maschine [root@localhost ~]# ls /nfs/ game.html Bilder index.html js-Stil ZugangstestDies ist das Ende dieses Artikels über die Bereitstellung von httpd im Quellcode von Docker-Containern und die Verwendung von Speichervolumes zum Bereitstellen von Websites. Weitere Informationen zur Bereitstellung von httpd im Docker-Container finden Sie in früheren Artikeln auf 123WORDPRESS.COM oder in den folgenden verwandten Artikeln. Ich hoffe, Sie werden 123WORDPRESS.COM auch in Zukunft unterstützen! Das könnte Sie auch interessieren:
|
<<: Zusammenfassung verschiedener Formen der Anwendung von CSS-Stilen in Webseiten
>>: Eine kurze Diskussion über HTML-geordnete Listen, ungeordnete Listen und Definitionslisten
In diesem Artikel wird der spezifische JavaScript...
Was ist ein MIME-TYP? 1. Zunächst müssen wir vers...
Sinnvolle Einstellung des MySQL sql_mode sql_mode...
Im vorherigen Artikel haben wir vorgestellt, wie ...
Problembeschreibung Wenn VMware Workstation eine ...
Inhaltsverzeichnis Vorwort HTTP HTTP-Server Datei...
Inhaltsverzeichnis 1. Hintergrund 2. Was ist ein ...
Inhaltsverzeichnis Vorwort So kapseln Sie eine To...
Reguläre Ausdrücke werden häufig verwendet, um Te...
Inhaltsverzeichnis 1. Master-Slave-Replikation Ma...
Der Befehl „Explain“ ist die primäre Möglichkeit,...
Empfohlene Docker-Lernmaterialien: https://www.ru...
0. Was ist ein Tag? XML/HTML-CodeInhalt in die Zw...
Vorwort Vor kurzem war ich damit beschäftigt, ein...
In diesem Artikel wird der spezifische Code für J...