(云原生之使用Docker部署轻量级web服务器lighthttpd)
一、Lighthttpd介绍
一个免费的Web服务器。这个开源Web服务器是快速,安全的,并且消耗更少的CPU功率。Lighttpd也可以在Windows,Mac OS X,Linux和Solaris操作系统上运行。
二、检查系统版本
[root@node mariadb]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
三、检查docker状态
[root@node mariadb]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2022-11-04 09:12:32 CST; 5h 17min ago
Docs: https://docs.docker.com
Main PID: 10162 (dockerd)
Tasks: 37
Memory: 702.1M
CGroup: /system.slice/docker.service
├─10162 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
├─21803 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 27217 -container-ip 172.17.0.2 -container-port 27017
├─21808 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 27217 -container-ip 172.17.0.2 -container-port 27017
├─33495 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 3548 -container-ip 172.17.0.3 -container-port 3306
└─33501 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 3548 -container-ip 172.17.0.3 -container-port 3306
Nov 04 09:14:43 node dockerd[10162]: time="2022-11-04T09:14:43.307093238+08:00" level=error msg="23b76c34a23fc0a5927af983429afc38073dd8e...ntainer"
Nov 04 09:14:43 node dockerd[10162]: time="2022-11-04T09:14:43.307154453+08:00" level=error msg="Handler for POST /v1.41/containers/23b76c34a23f...
Nov 04 09:16:17 node dockerd[10162]: time="2022-11-04T09:16:17.615100281+08:00" level=info msg="ignoring event" container=c6c46f42573372...kDelete"
Nov 04 09:31:27 node dockerd[10162]: time="2022-11-04T09:31:27.346146621+08:00" level=info msg="Attempting next endpoint for pull after ...unknown"
Nov 04 09:41:33 node dockerd[10162]: time="2022-11-04T09:41:33.324562841+08:00" level=error msg="Not continuing with pull after error: c...anceled"
Nov 04 10:00:54 node dockerd[10162]: time="2022-11-04T10:00:54.645415843+08:00" level=info msg="Attempting next endpoint for pull after ...unknown"
Nov 04 11:46:29 node dockerd[10162]: time="2022-11-04T11:46:29.261326827+08:00" level=info msg="Attempting next endpoint for pull after ...unknown"
Nov 04 11:47:04 node dockerd[10162]: time="2022-11-04T11:47:04.769147449+08:00" level=info msg="Download failed, retrying (1/5): net/htt...timeout"
Nov 04 11:51:16 node dockerd[10162]: time="2022-11-04T11:51:16.548891252+08:00" level=error msg="Not continuing with pull after error: c...anceled"
Nov 04 11:55:42 node dockerd[10162]: time="2022-11-04T11:55:42.370401579+08:00" level=info msg="ignoring event" container=ac860c2aa163e2...kDelete"
Hint: Some lines were ellipsized, use -l to show in full.
四、下载lighthttpd镜像
[root@node mariadb]# docker pull romainlecomte/lighthttpd-docker
Using default tag: latest
latest: Pulling from romainlecomte/lighthttpd-docker
Image docker.io/romainlecomte/lighthttpd-docker:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/
efd26ecc9548: Pull complete
a3ed95caeb02: Pull complete
3c295595ae25: Pull complete
bafb828dc19e: Pull complete
b11f2b6d4983: Pull complete
Digest: sha256:f2ee34c64f40473df1ec46232892c32a292456b8a1b8a53596a68cdc495a8f37
Status: Downloaded newer image for romainlecomte/lighthttpd-docker:latest
docker.io/romainlecomte/lighthttpd-docker:latest
五、部署lighthttpd
1.创建数据目录
[root@node mariadb]# mkdir -p /data/lighthttpd
[root@node mariadb]# cd /data/lighthttpd/
[root@node lighthttpd]#
2.创建lighthttpd容器
[root@node lighthttpd]# docker run -d --name my_web02 --restart always -v /data/lighthttpd/data:/var/www/ -p 8080:80 romainlecomte/lighthttpd-docker:latest
fd0d7d60901a5336c3b94332919b4f1ed7b855d14f73ef38af653e0a481726a5
3.查看容器状态
[root@node lighthttpd]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fd0d7d60901a romainlecomte/lighthttpd-docker:latest "lighttpd -D -f /etc…" 4 seconds ago Up 3 seconds 0.0.0.0:8080->80/tcp, :::8080->80/tcp my_web02
六、访问lighthttpd服务
七、编辑index.html
1.编辑index.html文件
echo "hello-lighthttpd--aa" > data/index.html