所以我在 docker-compose 中运行了以下内容:
version: "3.7"
services:
api:
build:
context: ../hikrr_API
dockerfile: Dockerfile
ports:
- "4000:4000"
# volumes:
# - ../hikrr_API:/usr/src/
gui:
build:
context: ../hikrr_GUI
dockerfile: Dockerfile
ports:
- "3000:3000"
volumes:
- ../hikrr_GUI:/usr/src/
stdin_open: true
environment:
- CHOKIDAR_USEPOLLING=true
api = 一个非常简单的节点应用程序,纯粹用于测试。
此应用程序的 docker 文件:
FROM node:13
# Create app directory
WORKDIR /usr/src/
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package.json ./
RUN npm install
# If you are building your code for production
# RUN npm ci --only=production
# Bundle app source
COPY . .
EXPOSE 4000
# CMD [ "npm", "run", "start:dev" ]
CMD [ "node", "app.js" ]
gui = React 应用程序。
当我执行 docker-compose up --build
时,我得到了预期的终端输出(没有错误)。
但是,当我尝试联系 api 服务时,通过 cURL 我得到 Error: socket hang up
curl --location --request GET 'http://localhost:4000'
在没有 docker 的情况下运行节点应用程序(在项目的根目录中运行 node app.js
)按预期工作。我可以使用上面的 cURL 来点击这个。
我将如何调试这个?有什么想法吗?
操作系统:Windows 10