json - 带有Angular 2的Docker:无法获取

标签 json angular docker

按照本教程,我们尝试使用Docker建立Angular 2应用程序:https://scotch.io/tutorials/create-a-mean-app-with-angular-2-and-docker-compose

应用程序已部署,但我们收到“无法获取/”

这是我们构建应用程序的方式:

sudo docker build -t frontend:dev .

这就是我们运行应用程序的方式
sudo docker run -d --name frontend -p 1014:4200 frontend:dev

我们的dockerfile与教程完全相同:
# Create image based on the official Node 6 image from dockerhub
FROM node:6

# Create a directory where our app will be placed
RUN mkdir -p /usr/src/app

# Change directory so that our commands run inside this new directory
WORKDIR /usr/src/app

# Copy dependency definitions
COPY package.json /usr/src/app

# Install dependecies
RUN npm install

# Get all the code needed to run the app
COPY . /usr/src/app

# Expose the port the app runs in
EXPOSE 4200

# Serve the app
CMD ["npm", "start"]

这是package.json的摘录
{
  "name": "courseka",
  "version": "0.0.0",
  "scripts": {
    "start": "ng serve -H 0.0.0.0"
    "build": "ng build"
  }
}

最后,来自index.html文件的内容
<html>
  <head>
    <base href="/">
  </head>
</html>

最佳答案

似乎问题是Linux-Windows问题。该应用程序的开发发生在Windows上,其中导入文件夹和类不区分大小写,而在Linux上,导入文件夹和类不区分大小写。

通过使用

-it

参数,记录所有输出

关于json - 带有Angular 2的Docker:无法获取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44455983/

相关文章:

javascript - JSON 解码数组不起作用,但相同的数据适用于 javascript

html - 当绑定(bind)到 ngFor 中的值时,Angular 指令会失去其样式

php - 多个网站的正确 Docker 设置

javascript - 在angularjs中直接在Factory上添加静态JSON

json - 如何获取 Spark 驱动程序指标 json?

html - 如何垂直对齐文本列表中的所有元素?

javascript - 模糊事件未在 IE 中触发 - Angular 2+

django - 无法在 nginx docker 容器上使用 http2

docker - 更新docker(18.09.0)会导致错误

javascript - 使用 Knockout 映射插件使用非规范化数据