按照本教程,我们尝试使用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/