Ubuntu中的Docker - Supervisor抛出ENOEXEC错误

Supervisor;supervisor.conf;logfile_maxbytes=50MB;loglevel=debug;debug;warn;trace);pidfile=/tmp/supervisord.pid;autostart=true:user=mongodb:
提问开始:

我有一个正在运行的Ubuntu Docker容器,它安装了python3.7、mongodb和supervisor。当我试图通过supervisor服务运行我的python脚本时,它抛出了以下错误:

supervisor: couldn't exec /data/code/venvs/cleverInvest/bin/python: ENOEXEC
supervisor: child process was not spawned

supervisor.conf

[supervisord]
;logfile=/var/app/logs/ ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB        ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=5           ; (num of main logfile rotation backups;default 10)
loglevel=debug                ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=true                ; (start in foreground if true;default false)
minfds=1024                  ; (min. avail startup file descriptors;default 1024)
minprocs=200                 ; (min. avail process descriptors;default 200)

[program:mongod]
;command=/usr/bin/mongod --config /etc/mongod.conf
command=/usr/bin/mongod
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
autorestart=true
user=mongodb
priority=100

[program:server]
priority=10
;directory=/data/code/
;command=python3 server.py
command=/data/code/venvs/cleverInvest/bin/python /data/code/server.py
user=root
autostart=true
autorestart=true

[program:cleverinvest]
priority=10
;directory=/data/code/
command=/data/code/venvs/cleverInvest/bin/python /data/code/main.py
;command=python3 main.py
user=root
autostart=true
autorestart=true

我已经尝试在python文件中添加一个!#/bin/sh,或者给他们一个777规则。似乎没有任何帮助。

这里是我的Dockerfile

FROM       ubuntu:latest
MAINTAINER Docker

# Update apt-get sources AND install MongoDB
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y software-properties-common
RUN apt install -y gnupg2
RUN gpg2 --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys F3B1AA8B

# Installation:
RUN add-apt-repository ppa:deadsnakes/ppa

RUN apt-get install -y python3.7
RUN apt-get install -y python3-pip
#Mongodb
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
RUN apt-add-repository 'deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse'

RUN apt-get update

RUN apt-get install -y mongodb-org

# Supervisor for starting multiple process in Docker
RUN apt-get -y install supervisor && \
  mkdir -p /var/log/supervisor && \
  mkdir -p /etc/supervisor/conf.d

ADD supervisor.conf /etc/supervisor.conf

# Create the MongoDB data directory
RUN mkdir -p /data/db

RUN chmod 777 /data/db

# Create the MongoDB data directory
RUN mkdir -p /data/code
RUN chmod 777 /data/code

RUN mongod --version

#RUN mongod --dbpath /data/db --fork --logpath /data/db/log

# COPY cleverInvest Code to Container
COPY dev /data/code

# Installing pip for python modules
RUN apt-get install -y python3-pip

# Install modules
WORKDIR /data/code/
RUN chmod +x -R *.py
RUN chmod 777 -R *
RUN pip3 install -r requirements.txt

RUN pip3 freeze

EXPOSE 80 27017

# Set /usr/bin/mongod as the dockerized entry-point application
CMD ["supervisord", "-c", "/etc/supervisor.conf"]

#ENTRYPOINT ["/bin/bash"]
回答开始:得票数 0

所以我自己想出来了,我想写出我的解决方案,以防其他人也有同样的问题。

我只是改变了启动python脚本的方法,使用全局安装的python版本,而不是通过virtualenv。所以我的supervisor.conf文件现在看起来像这样:

[supervisord]
;logfile=/var/app/logs/ ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB        ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=5           ; (num of main logfile rotation backups;default 10)
loglevel=debug                ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=true                ; (start in foreground if true;default false)
minfds=1024                  ; (min. avail startup file descriptors;default 1024)
minprocs=200                 ; (min. avail process descriptors;default 200)

[program:mongod]
;command=/usr/bin/mongod --config /etc/mongod.conf
command=/usr/bin/mongod
stdout_logfile=/var/log/supervisor/%(program_name)s.log
stderr_logfile=/var/log/supervisor/%(program_name)s.log
autorestart=true
user=mongodb
priority=100

[program:server]
priority=10
directory=/data/code/
command=python3 server.py
;command=/data/code/venvs/cleverInvest/bin/python /data/code/server.py
user=root
autostart=true
autorestart=true

[program:cleverinvest]
priority=10
directory=/data/code/
command=python3 main.py
;command=/data/code/venvs/cleverInvest/bin/python /data/code/main.py
user=root
autostart=true
autorestart=true

我的脚本文件中也有一个语法错误。在纠正它们之后,它起作用了。

总结

以上是真正的电脑专家为你收集整理的Ubuntu中的Docker - Supervisor抛出ENOEXEC错误的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得真正的电脑专家网站内容还不错,欢迎将真正的电脑专家推荐给好友。

你可能想看:
标签: dockerpython
分享给朋友: