[Python] No text message in logs or console when my flask app runs in a container

Discussão em 'Python' iniciado por Stack, Abril 16, 2025.

  1. Stack

    Stack Membro Participativo

    I am currently packaging an old python/flask/pandas application (MyApp) into a podman container.

    When MyApp runs directly in Ubuntu Console, text messages (e.g. user defined warnings and errors from pandas) are printed in the terminal. The application works smoothly. The prompts are:

    conda activate my_env
    python run.py


    When I build a podman image and run the container attached to a console, not a single text message is printed in the console or stored in logs. Some of the functions (e.g. download) of the application fails. The prompts are:

    podman build -t my_app .
    podman run -p 5000:5000 my_app
    podman logs -f {container_id}


    When I start the container and terminate it with Ctrl+C, only the "keyboard interrupt" error is recorded in logs - nothing else.

    What could be the reason? I am very new with container, Thanks!

    PS. the Dockerfile is:

    # Dockerfile
    FROM docker.io/continuumio/miniconda3:24.11.1-0
    ENV CONDA_ENV_NAME=my_env
    ENV ENV_FILE=environment.yml
    ENV APP_ENV_FILE=.env.dev
    ENV FLASK_APP=run.py
    ENV FLASK_ENV=development
    ENV PYTHONUNBUFFERED=1

    RUN echo Flask environment name: "$FLASK_ENV" # && true
    RUN echo Conda environment name: "$CONDA_ENV_NAME" && true

    RUN \
    apt-get update && \
    apt-get install -y zip

    WORKDIR /deployment

    COPY ./$ENV_FILE /deployment/$ENV_FILE
    RUN conda env create -y -n $CONDA_ENV_NAME -f /deployment/$ENV_FILE
    RUN conda run -n "$CONDA_ENV_NAME" conda info --envs
    RUN conda run -n "$CONDA_ENV_NAME" python --version
    RUN conda run -n "$CONDA_ENV_NAME" python -m flask --version

    COPY ./app /deployment/app
    COPY ./doc /deployment/doc
    COPY ./web /deployment/web
    COPY ./upload /deployment/upload
    COPY ./run.py /deployment/run.py
    COPY ./$APP_ENV_FILE /deployment/$APP_ENV_FILE

    EXPOSE 5000
    CMD ["/bin/bash", "-c", "conda run -n $CONDA_ENV_NAME python -u -m flask run --host=0.0.0.0"]

    Continue reading...

Compartilhe esta Página