【发布时间】:2018-12-18 17:54:36
【问题描述】:
我是 Angular 和 Docker 的新手。我开发了一个 Angular 7 应用程序并尝试对其进行 docker 化。我确实看过很多教程,并且能够构建 Docker 映像。 下面是我的 Dockerfile
FROM nginx:1.13.3-alpine
## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
COPY ./ /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
我使用命令运行 docker 容器
docker run -d --name containerName -p 8082:80 imagename
我的容器确实启动了,在浏览器 http://IP-address:8082/ 中查看后,我可以看到我的应用程序的 index html。除此之外,我的应用程序的其他 URL(如登录页面 (http://IP-address:8082/login) 或仪表板 (http://IP-address:8082/dashboard) 都不起作用。我看到 404 页面未找到问题。还缺少什么来确保路由在我的 dockerized 容器中正常工作?
下面是我的 default.conf 文件
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
我的 Docker 版本是 Docker 版本 17.03.2-ce。 任何帮助表示赞赏
【问题讨论】:
标签: angular docker dockerfile angular-routing angular7