云原生之使用Docker部署轻量级web服务器lighthttpd

简介: 云原生之使用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服务

在这里插入图片描述

相关文章
|
6月前
|
应用服务中间件 网络安全 nginx
手把手教你使用 Docker 部署 Nginx 教程
本文详解Nginx核心功能与Docker部署优势,涵盖镜像拉取、容器化部署(快速、挂载、Compose)、HTTPS配置及常见问题处理,助力高效搭建稳定Web服务。
2746 4
|
6月前
|
应用服务中间件 Linux nginx
在虚拟机Docker环境下部署Nginx的步骤。
以上就是在Docker环境下部署Nginx的步骤。需要注意,Docker和Nginix都有很多高级用法和细节需要掌握,以上只是一个基础入门级别的教程。如果你想要更深入地学习和使用它们,请参考官方文档或者其他专业书籍。
317 5
|
6月前
|
存储 NoSQL Redis
手把手教你用 Docker 部署 Redis
Redis是高性能内存数据库,支持多种数据结构,适用于缓存、消息队列等场景。本文介绍如何通过Docker快速拉取轩辕镜像并部署Redis,涵盖快速启动、持久化存储及docker-compose配置,助力开发者高效搭建稳定服务。
2031 9
|
6月前
|
存储 关系型数据库 MySQL
MySQL Docker 容器化部署全指南
MySQL是一款开源关系型数据库,广泛用于Web及企业应用。Docker容器化部署可解决环境不一致、依赖冲突问题,实现高效、隔离、轻量的MySQL服务运行,支持数据持久化与快速迁移,适用于开发、测试及生产环境。
929 4
|
数据采集 SQL 弹性计算
使用云服务器ECS部署了自己的第一个爬虫
云服务器部署爬虫爬取网站最新通告并推送
使用云服务器ECS部署了自己的第一个爬虫
|
6月前
|
弹性计算 运维 安全
阿里云轻量应用服务器与云服务器ECS啥区别?新手帮助教程
阿里云轻量应用服务器适合个人开发者搭建博客、测试环境等低流量场景,操作简单、成本低;ECS适用于企业级高负载业务,功能强大、灵活可扩展。二者在性能、网络、镜像及运维管理上差异显著,用户应根据实际需求选择。
519 10
|
6月前
|
运维 安全 Ubuntu
阿里云渠道商:服务器操作系统怎么选?
阿里云提供丰富操作系统镜像,涵盖Windows与主流Linux发行版。选型需综合技术兼容性、运维成本、安全稳定等因素。推荐Alibaba Cloud Linux、Ubuntu等用于Web与容器场景,Windows Server支撑.NET应用。建议优先选用LTS版本并进行测试验证,通过标准化镜像管理提升部署效率与一致性。
|
6月前
|
弹性计算 ice
阿里云4核8g服务器多少钱一年?1个月和1小时价格,省钱购买方法分享
阿里云4核8G服务器价格因实例类型而异,经济型e实例约159元/月,计算型c9i约371元/月,按小时计费最低0.45元。实际购买享折扣,1年最高可省至1578元,附主流ECS实例及CPU型号参考。
650 8
|
6月前
|
存储 监控 安全
阿里云渠道商:云服务器价格有什么变动?
阿里云带宽与存储费用呈基础资源降价、增值服务差异化趋势。企业应结合业务特点,通过阶梯计价、智能分层、弹性带宽等策略优化成本,借助云监控与预算预警机制,实现高效、可控的云资源管理。
下一篇
开通oss服务