0

I have basic project setup for flask project (nginx/postgresql/app) and every time i stop containers it takes about 10.3 second to stop. Nginx and postgres very quick to stop, but my application container takes too long to stop. My docker-compose.yml is below:

version: "3"

services:
    app:
        build:
            context: app
        ports:
            - "5000"
        environment:
            - POSTGRES_PASSWORD=password
            - POSTGRES_USER=postgres
            - POSTGRES_DB=flask
    nginx:
        image: nginx:latest
        volumes:
            - ./nginx.conf:/etc/nginx/nginx.conf:ro
        depends_on:
            - app
        ports:
            - "80:80"
    postgres:
        build:
            dockerfile: ./Dockerfile.postgres
        hostname: postgres.dev
        depends_on:
            - app
        environment:
            - POSTGRES_PASSWORD=password
            - POSTGRES_USER=postgres
            - POSTGRES_DB=flask

And Dockerfile for app container:

FROM python:latest
LABEL author "OllyHearn <longcat512@gmail.com>"
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
ENV FLASK_ENV="docker"
CMD gunicorn --bind 0.0.0.0:5000 app:app

Screenshot: This takes too long

Every time I wait for 10 seconds to reload containers, have you any suggestions how to make it quicker?

davidism
  • 121,510
  • 29
  • 395
  • 339
OllyHearn
  • 1
  • 2
  • Check this maybe this answers can help https://stackoverflow.com/questions/66504048/it-takes-too-long-to-shut-down-the-docker-container – Alasgar Oct 20 '22 at 16:25

0 Answers0