docker编译一个支持flv的nginx镜像

在本地下载编译了下

(参考:https://www.cnblogs.com/hhmm99/p/16050844.html)

相关文件下载

https://nginx.org/download/

https://gitee.com/winshining/nginx-http-flv-module

编译时缺少openssl报错

./configure: error: SSL modules require the OpenSSL library.

You can either do not enable the modules, or install the OpenSSL library

into the system, or build the OpenSSL library statically from the source

with nginx by using --with-openssl=<path> option.

复制代码
sudo apt install openssl libssl-dev

./configure --add-module=/home/dtjk/work_rtsp/nginx-http-flv-module --with-http_ssl_module
make
make install

不想执行最后一步make install而污染本地系统,

所以就放docker里面去了

docker编译镜像

  • 安装 Docker 确保你已经在系统上安装了 Docker。如果还没有安装,可以参考 Docker 官方安装文档

  • 创建 Dockerfile 创建一个新的目录来存放你的 Dockerfile 和相关文件。比如,nginx-flv.

复制代码
  mkdir nginx-flv
  cd nginx-flv
  • 编写 Dockerfilenginx-flv 目录中创建一个名为 Dockerfile 的文件,内容如下:

    使用官方的 Debian 镜像作为基础镜像

    FROM debian:latest

    安装必要的依赖

    RUN apt-get update && apt-get install -y
    build-essential
    libpcre3
    libpcre3-dev
    zlib1g
    zlib1g-dev
    libssl-dev
    wget

    下载并解压 Nginx 源码

    RUN wget http://nginx.org/download/nginx-1.24.0.tar.gz &&
    tar -zxvf nginx-1.24.0.tar.gz

    下载并解压 Nginx-RTMP 模块源码

    RUN wget https://gitee.com/winshining/nginx-http-flv-module/repository/archive/master.zip &&
    unzip master.zip

    编译 Nginx 并添加 RTMP 模块

    WORKDIR /nginx-1.24.0

    RUN ./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master &&
    make &&
    make install

    暴露 Nginx 默认端口

    EXPOSE 80 1935

    启动 Nginx

    CMD ["nginx", "-g", "daemon off;"]

构建 Docker 镜像

nginx-flv 目录中运行以下命令来构建 Docker 镜像:

复制代码
  docker build -t my-nginx-flv .
  • 运行 Docker 容器 构建完成后,你可以使用以下命令来运行一个基于新镜像的容器:

复制代码
  docker run --name my-nginx-flv-container -d -p 80:80 -p 1935:1935 my-nginx-flv

这样,你就可以访问运行在容器中的 Nginx 服务了。

  • 验证 打开浏览器,访问 http://localhost,确认 Nginx 已经成功启动。如果需要配置 Nginx 以支持 FLV 流媒体播放,你需要进一步调整 Nginx 的配置文件。

  • 修改 Nginx 配置 如果你需要自定义 Nginx 配置,可以在 Dockerfile 中添加复制配置文件的步骤。例如,将本地的 nginx.conf 文件复制到镜像的适当位置。

    Dockerfile

复制代码
   # 继续之前的 Dockerfile 内容
   COPY nginx.conf /usr/local/nginx/conf/nginx.conf

用这种方式,你可以灵活地调整和扩展 Nginx 的功能,满足各种需求。

相关推荐
邂逅星河浪漫1 天前
【Docker+Nginx+Ollama】前后端分离式项目部署(传统打包方式)
java·nginx·docker·部署
IT成长日记1 天前
【Nginx开荒攻略】Nginx主配置文件结构与核心模块详解:从0到1掌握nginx.conf:
linux·运维·nginx·配置文件
linweidong1 天前
解锁 Ray 在 Kubernetes 上的弹性伸缩:打造高效、稳定的分布式作业
分布式·容器·kubernetes·ray·keda·autoscaling·ray推理
咖啡Beans1 天前
Docker安装ELK(Elasticsearch + Logstash + Kibana)
后端·elasticsearch·docker
ZzzZZzzzZZZzzzz…1 天前
Nginx_Tomcat综合案例
运维·nginx·tomcat·负载均衡·rhce·反向代理·https加密服务
智能化咨询1 天前
Docker 容器化部署核心实战——Nginx 服务配置与正反向代理原理解析
docker
有谁看见我的剑了?1 天前
k8s-init容器学习
学习·容器·kubernetes
人工干智能2 天前
科普:在Windows个人电脑上使用Docker的极简指南
windows·docker·容器
lllsure2 天前
【Docker】容器
运维·docker·容器
烟雨书信2 天前
LINUX中Docker Swarm的介绍和使用
java·linux·docker