遵循本教程,我们将尝试使用Docker设置一个Angular 2应用程序:https://scotch.io/tutorials/create-a-mean-app-with-angular-2-and-docker-compose
应用程序被部署,但是我们得到'Cannot get /‘
这是我们如何构建我们的应用程序:
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>https://stackoverflow.com/questions/44455983
复制相似问题