2017-04-13 85 views
0

我正在使用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 

回答

0

缺少Angular CLI的dev依賴關係。我不確定這是否是唯一的問題,但它會導致您收到的錯誤ng

0

你的「npm start」命令失敗。 檢出輸出來自kitematic,那裏的錯誤日誌可能會導致您遇到問題