本文介绍了UserWarning:Supervisord以root身份运行,并且正在默认位置搜索其配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了一个docker镜像 docker build -t ds_backend。,并在下面的错误之后提到了所有配置。

I have built one docker image docker build -t ds_backend . with all congiguration mentioned after the error below.

要使用 docker运行映像,请运行ds_backend 及其给出的以下错误。

While trying to run the image using docker run ds_backend and its giving following error.

/usr/lib/python2.7/dist-packages/supervisor/options.py:461: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
  'Supervisord is running as root and it is searching '
2020-08-27 01:53:36,963 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
2020-08-27 01:53:36,966 INFO supervisord started with pid 1

这是我的配置文件

Dockerfile

Dockerfile

FROM python:3.6

MAINTAINER Dockerfiles

RUN mkdir /trell-ds-framework
WORKDIR /trell-ds-framework
ADD . /trell-ds-framework/
RUN python3 setup.py bdist_wheel
# install uwsgi now because it takes a little while
RUN pip3 install uwsgi
# copy over our requirements.txt file
# upgrade pip and install required python packages
RUN pip3 --no-cache-dir install -U pip
RUN apt-get install -y ca-certificates
RUN apt-get update && \
    apt-get install -y software-properties-common && \
    rm -rf /var/lib/apt/lists/*
# RUN add-apt-repository universe
RUN apt-get update
RUN apt-get install -y supervisor
RUN apt-get install -y ca-certificates supervisor
COPY supervisor_app.conf /etc/supervisor/conf.d/supervisord.conf
RUN apt-get update && apt-get -y install cron
RUN pip3 --no-cache-dir install -r requirements.txt
RUN python3 -c "import nltk;nltk.download('stopwords')"
# setup all the configfiles
# RUN echo "daemon off;" >> /etc/nginx/nginx.conf
# RUN /usr/sbin/nginx -g "daemon off;"
COPY nginx_app.conf /etc/nginx/sites-available/default
COPY supervisor_app.conf /etc/supervisor/conf.d/


# add (the rest of) our code

EXPOSE 80
# CMD ["supervisord"]
CMD ["/usr/bin/supervisord"]

supervisor_app.conf

supervisor_app.conf

[supervisord]
nodaemon=true
user=root


[program:uwsgi]
command = /usr/local/bin/uwsgi --ini /trell-ds-framework/uwsgi.ini
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:nginx]
command = /usr/sbin/nginx -g "daemon off;"
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
daemon=off

nginx_app.conf

nginx_app.conf

server {
    listen 80 default_server;
    server_name ip;

    # max upload size
    client_max_body_size 75M;   # adjust to taste

    location / {
        include uwsgi_params;
        uwsgi_pass unix:///trell-ds-framework/app.sock;
    }
}

uwsgi.ini文件

uwsgi.ini file

[uwsgi]
callable = app
chdir = /trell-ds-framework
wsgi-file = /trell-ds-framework/wsgi.py
socket = /trell-ds-framework/app.sock
master = true
processes = 2
chmod-socket = 666
enable-threads = true
user=root
Can anybody guide me here if I am doing something wrong ? Any leads highly appreciated. Thanks.


推荐答案

通过设计:


  • 如果未指定USER,则docker容器将以root身份运行

  • supervisor不允许以root身份运行守护程序,而无需在配置文件中明确指定。

因此,您可以以root以外的用户身份运行超级用户,也可以只添加 user = root

So you can either run supervisor as a user other than root or just add the user=root directive into the configs.

[supervisord]
nodaemon=true
user=root


[program:uwsgi]
command = /usr/local/bin/uwsgi --ini /trell-ds-framework/uwsgi.ini
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
user=root

[program:nginx]
command = /usr/sbin/nginx -g "daemon off;"
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
daemon=off
user=root ;here too if you want to

这篇关于UserWarning:Supervisord以root身份运行,并且正在默认位置搜索其配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-22 22:48