Docker 容器无法启动

时间:2021-01-17 06:25:47

标签: node.js docker docker-compose

我正在尝试在 Github 容器中的 Docker 中运行此 project。这是一个简单的 reactjs 状态应用程序。

我尝试在克隆后使用以下命令在本地环境中运行它:

// install dependencies
npm install

// and then
npm start

而且工作正常。

然后我用 Dockerfile 做了同样的事情,如下:

# Use whatever version you are running locally (see node -v)
FROM node:12.13

WORKDIR /

COPY package.json /


RUN npm install

COPY . /


EXPOSE 3000

CMD ["npm", "start"]

当我使用 docker-compose.yml 使用 docker-compose up --build -d 构建如下时:

version: "3.2"

services:
  frontend_common:
    build: .
    ports:
      - 80:3000
       

但是容器退出,当我尝试查看日志时,它没有给出错误,但输出如下:


> issue-status@0.1.0 start /
> react-scripts start

ℹ 「wds」: Project is running at http://<Redacted>/
ℹ 「wds」: webpack output is served from
ℹ 「wds」: Content not from webpack is served from /public
ℹ 「wds」: 404s will fallback to /
Starting the development server...

有人可以帮助我哪里出错了吗?

1 个答案:

答案 0 :(得分:1)

看来,这是您在使用 react-scripts@3.4.1 时遇到的常见问题。您可以关注该问题并查看推荐的解决方法,例如 github

降级或在 docker-compose 文件中添加 following line

stdin_open: true

docker-compose.yaml

version: "3.2"

services:
  frontend_common:
    build: .
    ports:
      - 80:3000
    stdin_open: true