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

问题描述:

我正在使用angular2和docker并尝试构建图像。当我在中输入 “docker build -t angular-client:dev”。似乎一切正常,但 当我运行角客户端尝试创建一个容器,它开始和比 停止。请有人能帮我弄清楚这个.....在Docker中创建ng-cli容器不起作用

**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 [email protected]~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! [email protected] start: `ng serve --host 0.0.0.0` 
npm ERR! spawn ENOENT 
npm ERR! 
npm ERR! Failed at the [email protected] 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 

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

你的“npm start”命令失败。 检出输出来自kitematic,那里的错误日志可能会导致您遇到问题