Search code examples
dockerpython-poetry

Poetry echos " Skipping virtualenv creation, as specified in config file" when run in Docker


I have a Dockerised Python set up with

RUN poetry config virtualenvs.create false
RUN poetry install --no-dev --no-interaction --no-ansi mypackage

Now when I run this using:

docker run mycontainer

I get extra warning message before my application starts:

Skipping virtualenv creation, as specified in config file

How do I suppress this message?


Solution

  • You can pass --quiet flag to poetry

    If you are using an entry point shell script you can do:

    #!/bin/bash
    #
    # Start trade-executor under docker compose
    #
    
    poetry --quiet run mypackage "$@"
    

    With the following in Dockerfile

    ENTRYPOINT ["scripts/docker-entrypoint.sh"]
    

    Or you can change the command in Dockerfile:

    CMD ["poetry",  "--quiet", "run", "mypackage"]