Python Supervisord running flask应用程序调用docker应用程序

Python Supervisord running flask应用程序调用docker应用程序,python,flask,docker,gunicorn,supervisord,Python,Flask,Docker,Gunicorn,Supervisord,我有一个flask应用程序,它使用子流程调用我的停靠应用程序 @app.route('/detect', methods=['POST']) def detect_file(): file = request.files['wireframe'] if file and allowed_file(file.filename): filename = str(uuid.uuid4()) + getFileExtension(file.filename)

我有一个flask应用程序,它使用
子流程
调用我的停靠应用程序

@app.route('/detect', methods=['POST'])
def detect_file():
    file = request.files['wireframe']
    if file and allowed_file(file.filename):
        filename = str(uuid.uuid4()) + getFileExtension(file.filename)
        file.save(os.path.join(app.config['UPLOAD_FOLDER'],
                    filename))
    p = subprocess.Popen(["docker","run","-v","/home/ganaraj/contours/upload:/detect","-w",
            "/detect","-it","--rm","opecv3", "./prediction",
                   filename ], stdout=subprocess.PIPE)
    output, err = p.communicate()
    return jsonify(result=output.rstrip())
    return jsonify(error='Mismatch file type')
当我自己运行flask应用程序
python app.py
时,它运行得很好。我从停靠的应用程序返回一个结果。 当我直接使用gunicorn运行flask应用程序时,
gunicorn wsgi.py

当我通过gunicorn运行flask应用程序并使用supervisor使其继续运行时-应用程序启动-api的工作正常,但停靠的部分除外。 我猜这与某种类型的权限有关,但我不知道我到底需要做什么来解决这个问题

这是我的
supervisord.conf
供参考

[program:cvupload]
command = /root/anaconda/envs/cvuload/bin/gunicorn -b 0.0.0.0:9000 --debug --log-level debug wsgi:app
directory = /home/ganaraj/contours
user=root

我是否需要对整个工具链的任何部分进行任何更改以使其正常工作

当它工作正常时,您使用的用户是什么?您的工作目录是什么?您是否激活了任何virtualenv?您是否导出任何环境变量?
docker
通常需要sudo,除非您允许用户或组在没有sudo的情况下访问它。运行你的应用程序的用户有吗?@dopstar:我确实激活了虚拟环境。没有导出任何环境变量。@dirn:supervisor是用root用户启动的
user=root
-我说得对吗?当
root
有sudo权限时,我问它是否有权在没有sudo的情况下运行Docker命令。当它工作正常时,你使用的用户是什么?你的工作目录是什么?您是否激活了任何virtualenv?您是否导出任何环境变量?
docker
通常需要sudo,除非您允许用户或组在没有sudo的情况下访问它。运行你的应用程序的用户有吗?@dopstar:我确实激活了虚拟环境。未导出任何环境变量。@dirn:supervisor是用root user
user=root启动的
-我说得对吗?虽然
root
有sudo权限,但我询问它是否有权在没有sudo的情况下运行Docker命令。