0

I have a problem with sending post requests to docker container build up with docker-compose method. When I send post request I receive 405 error -> "message": "The method is not allowed for the requested URL.". What is important is the fact that post requests work when I use the same container with docker run command. I guess that the problem might be docker-compose.yml file.

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" 

Thanks for any help in advance!

1
  • Now even with docker run post requests are not working :c Commented Dec 20, 2019 at 14:13

1 Answer 1

3

Environment varibles should be a list

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

Also I don't see environment file in your docker-compose file. Refer this URL for more details.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for reply. Iif I add dashes like You did I got an error code ERROR: The Compose file './docker-compose.yml' is invalid because: services.intent-handler.environment contains {"GOOGLE_APPLICATION_CREDENTIALS": {"config/enviroment_variables/df-handling-test-4c3d81541aad.json": null}}, which is an invalid type, it should be a string
How are you passing the variables? I had made a typo in my above reply, corrected it now. Correction --> variable_name=${value}
@Nitish docker compose will look for a .env file in the directory in which you run the command. It is not required to be explicitly specified in the docker-compose.yml file.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.