我正在嘗試對我的 Angular 應用程式進行 docker 化。當我進入網頁時,一切正常,直到我重繪 頁面 (F5)。當我使用 nginx:1.17.1-alpine 作為基礎映像時,我通過使用以下 nginx.conf 檔案而不是 nginx.conf 默認檔案來解決問題:
server {
listen 4200;
server_name localhost;
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}}
我的 dockerfile 看起來像這樣:
FROM nginx:1.17.1-alpine
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY /dist/frontend /usr/share/nginx/html
EXPOSE 4200
但是現在我需要使用 bitnami/nginx:1.21.6-debian-10-r88 作為我的基礎鏡像。當我嘗試構建容器時,出現以下錯誤:
RUN rm /etc/nginx/conf.d/default.conf:
#15 0.399 rm: cannot remove '/etc/nginx/conf.d/default.conf': No such
file or directory
任何人都可以幫助我弄清楚如何正確構建容器?
uj5u.com熱心網友回復:
nginx 配置位于/opt/bitnami/nginx/conf
如自述檔案中所述,Step 1您可以將服務器塊配置復制到
/opt/bitnami/nginx/conf/server_blocks/my_server_block.conf
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/465282.html
