2017-02-07 72 views
3

我正在使用AWS ECS上的docker部署create-react-app。我正在測試使用dockerhub圖像,這幾乎是create-react-app的股票版本。啓動任務時,它能夠拉取容器圖像,啓動Docker容器,但是它會在運行react-scripts start時掛起。我可以在容器日誌中看到如下:如何調試react-scripts掛?

01:51:38 npm info it worked if it ends with ok 
01:51:38 npm info using [email protected] 
01:51:38 npm info using [email protected] 
01:51:42 npm info prestart [email protected] 
01:51:42 npm info start [email protected] 
01:51:42 > [email protected] start /usr/src/app 
01:51:42 > react-scripts start 
01:52:06 Starting the development server... 

它只是掛在那兒,從來沒有完成。然而,當我手動運行泊塢窗容器,一切工作正常:

Starting the development server... 
Compiled successfully! 

The app is running at: 

    http://localhost:3000/ 

我Dockerfile是:

FROM node:4-onbuild 

# Prepare app directory 
RUN mkdir -p /usr/src/app 
ADD . /usr/src/app 

# Install dependencies 
WORKDIR /usr/src/app 
RUN npm install 

# Build the app 
RUN npm build 

# Expose the app port 
EXPOSE 3000 

# Start the app 
CMD npm start --loglevel debug 

我的package.json:

"scripts": { 
     "start": "react-scripts start", 
     "build": "react-scripts build", 
     "test": "react-scripts test --env=jsdom", 
     "eject": "react-scripts eject" 
    } 
    } 

尋找諮詢如何調試,或者如果還有其他日誌記錄,我可以做,謝謝!

回答

3

我想通了 - 當我在ECS任務中定義了容器時,我沒有爲Docker容器分配足夠的內存,所以當它啓動服務器時,內存不足並且凍結了。我改變了設置以分配更多的內存到碼頭集裝箱,現在一切正常。

+1

感謝您回來發佈您的解決方案。你剛剛救了我。我一直在尋找一個解決方案大約一週。 – andrewcopp