gpt4 book ai didi

python-3.x - POST请求在docker-compose容器中不起作用

转载 作者:行者123 更新时间:2023-12-02 20:43:25 25 4
gpt4 key购买 nike

我在将发布请求发送到使用docker-compose方法构建的docker容器时遇到问题。当我发送发布请求时,我收到405错误->“消息”:“该方法不适用于所请求的URL。”。重要的是,当我将同一容器与docker run命令一起使用时,发布请求会起作用。我想问题可能出在docker-compose.yml文件上。

Dokckerfile

FROM python:3.6-alpine

EXPOSE 5005
WORKDIR /dialogflow_nlp_connector
COPY requirements.txt /dialogflow_nlp_connector
RUN apk add --no-cache --virtual .build-deps g++ musl-dev
RUN pip install -r requirements.txt
COPY . /dialogflow_nlp_connector/

CMD ["python", "run.py"]

Docker-Compose.yml
version: "3"

services:
intent-handler:
build: ./intent_handling
volumes:
- ./intent_handling:/dialogflow_nlp_connector
environment:
GOOGLE_APPLICATION_CREDENTIALS: ${GOOGLE_APPLICATION_CREDENTIALS}
DIALOGFLOW_PROJECT_ID: ${DIALOGFLOW_PROJECT_ID}
ports:
- "5005:5005"

slack_event_handler:
build: ./slack_events_api
volumes:
- ./slack_events_api:/slack_event_handler
environment:
SLACK_BOT_TOKEN: ${SLACK_BOT_TOKEN}
SLACK_SIGNING_TOKEN: ${SLACK_SIGNING_TOKEN}
SLACK_VERIFICATION_TOKEN: ${SLACK_VERIFICATION_TOKEN}
FALLBACK_MESSAGE: "Sorry something went wrong :c Please try again in a moment!"
ports:
- "3000:3000"

感谢您的任何帮助!

最佳答案

环境变量应该列出

environment:
- GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS}
- DIALOGFLOW_PROJECT_ID=${DIALOGFLOW_PROJECT_ID}

另外我在您的docker-compose文件中没有看到环境文件。有关更多详细信息,请引用此 URL

关于python-3.x - POST请求在docker-compose容器中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59426038/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com