云原生之使用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

2.重新访问lighthttpd服务

在这里插入图片描述

  • 5
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

江湖有缘

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值