要用到 Nginx 的额外功能, 我需要安装插件合集 nginx-extras
. 但是官方 Nginx 镜像并不提供插件功能, 而我也不想就为了这么一个小功能就去用别人自己 Build 的镜像, 鬼知道里面有什么东西.
我了解到 官方 Nginx, 如果没有特殊指定的话, 是基于 Debian 的. 那么在 Debian 里面如果我想要安装这个插件, 我只需要执行以下命令, 就可以用了
apt-get update && apt-get install -y nginx-extras
经过简单的搜索, 我发现 Docker 提供 Dockerfile
的方法来构建自己的镜像. 就是一个小脚本, 有点像 Git Actions 那样的小脚本, 不过比那个还简单.

知道了 Dockerfile 怎么使用之后, 就可以上手了
FROM nginx:latest RUN apt-get update RUN apt-get install -y nginx-extras
docker build -t nginx_extras . docker image ls
因为我用了 Portainer, 我可以直接替换镜像为我自己构建的 nginx_extras
.

到此为止, Nginx 已经可以用上这些插件了.