linux - 带有 envsubt 的 Dockerfile
问题描述
FROM nginx:alpine
COPY /build /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
#COPY nginx/nginx.conf /etc/nginx/conf.d
COPY nginx/nginx.template /etc/nginx/conf.d
EXPOSE 80
CMD envsubst < /etc/nginx/conf.d/nginx.template > /etc/nginx/conf.d/nginx.conf && exec nginx -g 'daemon off;'
我的 nginx.conf 文件。
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
我的模板文件
server {
listen ${PORT};
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
以上是我的dockerfile。启动容器后,我检查了 config.d 文件夹,没有找到任何 nginx.conf 文件。似乎它没有使用 envsubt 生成任何文件。但后来我跳到交互模式并运行 envsubt 命令它确实生成了文件。我的情况似乎是什么问题?
解决方案
推荐阅读
- c++ - 当两个 std::map 对象相同时
- sql - DB2 中的 PLSQL 是否支持嵌套的 while 语句?
- c# - Regex.Matches 为正则表达式 c# 抛出异常
- javascript - Vue中双向绑定props的正确方式是什么?
- azure - 如何为 Container Registry Azure 创建只读访问密钥
- python - 按跨年的日历周分组
- mysql - 这个“医疗保健”数据库的 sql 查询代码是什么?
- asp.net - 超时后处理“无法解密防伪令牌”错误
- ios - AVAssetWriter 将图像写入 mp4 文件,但文件内容只有一半
- java - NiFi 开发自定义处理器:import org.apache.nifi.processors 错误