简体   繁体   中英

How to change chdir in python3 with comandline args

How to change chdir in python3 with comandline args like

python3 project_name/manage.py --chdir=/project_name

Actually I try to setup Docker to run flask app with next settings

version: '3'

services:

  flask:
    build: .
    restart: always
    container_name: 'project_name'
    command: python3 /project_name/manage.py --chdir=/project_name
#    command: gunicorn --bind 0.0.0.0:8000 --worker-class=gevent --workers=4 --chdir /flask --reload wsgi:app
    volumes:
      - .:/flask
    ports:
      - '8000:8000'
    environment:
        - PATH=/project_name:$PATH

And after all python says that it cannot find db file, I know why, because chdir is not root of project, chdir is a folder under the project dir

bash -c "cd /project_name && python3 manage.py"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM