在docker中创建ng-cli容器不起作用

时间:2017-04-13 22:06:59

标签: angular docker

我正在使用angular2和docker并尝试构建图像。当我进入    在“docker build -t angular-client:dev。”一切似乎都有效    当我运行angular-client尝试创建一个容器时,它启动而不是    停止。请有人帮我解决这个问题.....

**My 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"]


**My package.Json** 

 {
"name": "angular-client",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve --host 0.0.0.0",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "~2.1.0",
"@angular/compiler": "~2.1.0",
"@angular/core": "~2.1.0",
"@angular/forms": "~2.1.0",
"@angular/http": "~2.1.0",
"@angular/platform-browser": "~2.1.0",
"@angular/platform-browser-dynamic": "~2.1.0",
"@angular/router": "~3.1.0",
"core-js": "^2.4.1",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"
},
"devDependencies": {
"@types/jasmine": "^2.2.30",
"@types/node": "^6.0.42",
"codelyzer": "1.0.0-beta.1",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.9",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "~2.0.3",
"webdriver-manager": "10.2.5"
  }
 }

 **The output coming from kitematic**

 npm info lifecycle angular-client@0.0.0~start: Failed to exec start script
 npm ERR! Linux 4.4.59-boot2docker
 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
 npm ERR! node v6.10.2
 npm ERR! npm  v3.10.10
 npm ERR! file sh
 npm ERR! code ELIFECYCLE
 npm ERR! errno ENOENT
 npm ERR! syscall spawn
 npm ERR! angular-client@0.0.0 start: `ng serve --host 0.0.0.0`
 npm ERR! spawn ENOENT
 npm ERR! 
 npm ERR! Failed at the angular-client@0.0.0 start script 'ng serve --host 
 0.0.0.0'.
 npm ERR! Make sure you have the latest version of node.js and npm 
 installed.
 npm ERR! If you do, this is most likely a problem with the angular-client 
 package,
 npm ERR! not with npm itself.
 npm ERR! Tell the author that this fails on your system:
 npm ERR!     ng serve --host 0.0.0.0
 npm ERR! You can get information on how to open an issue for this project 
 with:
 npm ERR!     npm bugs angular-client
 npm ERR! Or if that isn't available, you can get their info via:
 npm ERR!     npm owner ls angular-client
 npm ERR! There is likely additional logging output above.
 npm ERR! Please include the following file with any support request:
 npm ERR!     /usr/src/app/npm-debug.log

2 个答案:

答案 0 :(得分:0)

您的“npm start”命令失败。 查看来自kitematic的输出,错误日志可能会导致您出现问题

答案 1 :(得分:0)

缺少Angular CLI的dev依赖项。我不确定这是唯一的问题,但会导致您收到 ng serve 错误。