Prisma,MongoDB,Docker“对http:// localhost:4466 /的请求失败,原因:连接ECONNREFUSED 127.0.0.1:4466”

时间:2019-06-28 17:15:55

标签: mongodb docker docker-compose prisma prisma-graphql

启动docker-compose up命令后,一切启动,并且运行prisma deploy也可以正常工作,但是我的应用程序仍然返回上述错误。我已经尝试了几天的解决方案,并且在线上没有任何帮助,并且一些类似的问题已被关闭或忽略。希望获得有关此问题的帮助。

这是我的 docker-compose.yml 文件:

version: '3'
services:
  prisma:
    env_file:
      - .env
    image: prismagraphql/prisma:1.34
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        databases:
          default:
            connector: mongo
            uri: ${MONGODB_URI}
            host: host.docker.internal
      JWT_SECRET: ${JWT_SECRET}
  mongo:
    env_file:
      - .env
    image: mongo:3.6
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: ${MONGODB_USERNAME}
      MONGO_INITDB_ROOT_PASSWORD: ${MONGODB_PASSWORD}
    ports:
      - "27017:27017"
    volumes:
      - mongo:/var/lib/mongo
  web:
    env_file:
      - .env
    build: .
    volumes:
      - .:/usr/app/
      - /usr/app/node_modules
    ports:
      - "4000:4000"
    environment:
      DATABASE_URL: ${MONGODB_URI}

volumes:
  mongo:

我的 Dockerfile

FROM node:8.16.0-alpine
WORKDIR /usr/app
COPY package.json .
RUN npm install --quiet
COPY . .

ENV DOCKERIZE_VERSION v0.6.0
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
    && tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
    && rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz

CMD dockerize -wait tcp://mongo:27017 -wait tcp://prisma:4466 -timeout 60m npm start

我的 prisma.yml

endpoint: http://localhost:4466
datamodel: 
  - db/types.prisma
  - db/enums.prisma
databaseType: document

generate:
  - generator: javascript-client
    output: ./generated/prisma-client/

我的prisma deploy命令有效,并且生成了mongo数据库,但是当我尝试在 localhost:4000 查询我的应用程序时,它看起来像这样,并返回以下错误:

request to http://localhost:4466/ failed, reason: connect ECONNREFUSED 127.0.0.1:4466

但是,当我导航到 localhost:4466 / _admin 时,数据库都已正确设置,并显示了应该存在的三个表。

我通过发出以下命令检查了是否有任何运行localhost:4466的命令:lsof -i :4466,并且我可以看到docker已正确启动。

COMMAND    PID        USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
com.docke 5923 sguduguntla   24u  IPv4 0x89ea943c9b98ff09      0t0  TCP *:4466 (LISTEN)
com.docke 5923 sguduguntla   25u  IPv6 0x89ea943c87111549      0t0  TCP localhost:4466 (LISTEN)

当我运行docker ps时,您还可以看到带有三张图像的以下输出:

CONTAINER ID        IMAGE                            COMMAND                  CREATED             STATUS              PORTS                      NAMES
fa70fae37f10        prismagraphql/prisma:1.34        "/bin/sh -c /app/sta…"   35 minutes ago      Up 31 minutes       0.0.0.0:4466->4466/tcp     decal-board-graphql-server_prisma_1
d64b9f6dcd29        decal-board-graphql-server_web   "docker-entrypoint.s…"   35 minutes ago      Up 31 minutes       0.0.0.0:4000->4000/tcp     decal-board-graphql-server_web_1
6f7dda5e58a0        mongo:3.6                        "docker-entrypoint.s…"   35 minutes ago      Up 31 minutes       0.0.0.0:27017->27017/tcp   decal-board-graphql-server_mongo_1

0 个答案:

没有答案