Docker compose 主管可以';t运行docker compose up命令

Docker compose 主管可以';t运行docker compose up命令,docker-compose,supervisord,Docker Compose,Supervisord,我试图使用supervisor监控多个docker流程,但我已经尽了全力,但没有结果。出于某种原因,主管总是说它找不到命令docker compose。我已经在我的机器上指向了docker compose的箱子,但它仍然不起作用,如果有人能帮忙,我将不胜感激。 这是我的supervisord.conf文件 ; Sample supervisor config file. ; ; For more information on the config file, please see: ; http

我试图使用supervisor监控多个docker流程,但我已经尽了全力,但没有结果。出于某种原因,主管总是说它找不到命令docker compose。我已经在我的机器上指向了docker compose的箱子,但它仍然不起作用,如果有人能帮忙,我将不胜感激。 这是我的supervisord.conf文件

; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Note: shell expansion ("~" or "$HOME") is not supported.  Environment
; variables can be expanded using this syntax: "%(ENV_HOME)s".

[unix_http_server]
file=/tmp/supervisor.sock   ; (the path to the socket file)
chmod=0700                 ; socket file mode (default 0700)


[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket
serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
username=socialhub              ; (default is no username (open server))
password=socialhub              ; (default is no password (open server))

[inet_http_server]          ; inet (TCP) server disabled by default
port=127.0.0.1:9001         ; (ip_address:port specifier, *:port for all iface)
username=socialhub              ; (default is no username (open server))
password=socialhub              ; (default is no password (open server))

[supervisord]
logfile=supervisord/supervisord.log     ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=0              ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10                  ; (num of main logfile rotation backups;default 10)
loglevel=info                       ; (log level;default info; others: debug,warn,trace)
pidfile=supervisord/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false                      ; (start in foreground if true;default false)
minfds=1024                         ; (min. avail startup file descriptors;default 1024)
minprocs=200                        ; (min. avail process descriptors;default 200)
nocleanup=false                     ; (don't clean up tempfiles at start;default false)

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface


; The below sample program section shows all possible program subsection values,
; create one or more 'real' program: sections to be able to control them under
; supervisor.

[program:mongo]
command=/usr/local/bin/docker-compose up mongodb    ; the program (relative uses PATH, can take args)
process_name=%(program_name)s               ; process_name expr (default %(program_name)s)
numprocs=1                                  ; number of processes copies to start (def 1)
directory=supervisord                           ; directory to cwd to before exec (def no cwd)
priority=1000                               ; the relative start priority (default 999)
autostart=true                              ; start at supervisord start (default: true)
autorestart=unexpected                      ; whether/when to restart (default: unexpected)
startsecs=60                                ; number of secs prog must stay running (def. 1)
startretries=5                              ; max # of serial start failures (default 3)
;exitcodes=0,2                              ; 'expected' exit codes for process (default 0,2)
stopsignal=QUIT                             ; signal used to kill process (default TERM)
stopwaitsecs=1                              ; max num secs to wait b4 SIGKILL (default 10)
stopasgroup=false                           ; send stop signal to the UNIX process group (default false)
killasgroup=false                           ; SIGKILL the UNIX process group (def false)
stdout_logfile=supervisord/                 ; stdout log path, NONE for none; default AUTO
stdout_logfile_maxbytes=0                   ; max # logfile bytes b4 rotation (default 50MB)
stderr_logfile=supervisord/                 ; stderr log path, NONE for none; default AUTO
stderr_logfile_maxbytes=10MB                ; max # logfile bytes b4 rotation (default 50MB)
stderr_logfile_backups=5                    ; # of stderr logfile backups (default 10)
stderr_events_enabled=true                  ; emit events on stderr writes (default false)


; The below sample eventlistener section shows all possible
; eventlistener subsection values, create one or more 'real'
; eventlistener: sections to be able to handle event notifications
; sent by supervisor.

[eventlistener:process_fail]
command=/usr/local/bin/docker-compose rm -f     ; the program (relative uses PATH, can take args)
process_name=%(program_name)s       ; process_name expr (default %(program_name)s)
numprocs=1                          ; number of processes copies to start (def 1)
events=PROCESS_LOG_STDERR               ; event notif. types to subscribe to (req'd)
buffer_size=10                      ; event buffer queue size (default 10)
directory=supervisord/                  ; directory to cwd to before exec (def no cwd)
priority=-1                         ; the relative start priority (default -1)
autostart=true                      ; start at supervisord start (default: true)
autorestart=unexpected              ; whether/when to restart (default: unexpected)
startsecs=1                         ; number of secs prog must stay running (def. 1)
startretries=3                      ; max # of serial start failures (default 3)
exitcodes=0,2                       ; 'expected' exit codes for process (default 0,2)
stopsignal=QUIT                     ; signal used to kill process (default TERM)
stopwaitsecs=1                      ; max num secs to wait b4 SIGKILL (default 10)
stopasgroup=false                   ; send stop signal to the UNIX process group (default false)
killasgroup=false                   ; SIGKILL the UNIX process group (def false)
;user=chrism                        ; setuid to this UNIX account to run the program
redirect_stderr=false               ; redirect proc stderr to stdout (default false)
stdout_logfile=NONE             ; stdout log path, NONE for none; default AUTO

您使用的目录不正确

directory=supervisord   
您应该使用您的
docker compose.yml
文件所在目录的完整路径

编辑-1:

所以我必须为你们的问题挖得更深一点。在版本
3.0b2
之前,无法正确传递命令中的空格

如果升级到
3.0.1
或更高版本,则使用空格的命令可以正常工作。在您的版本中,它获取命令的全部值并尝试将其作为文件定位,这就是为什么您会看到
命令未找到
错误

您可以使用
pip

pip install supervisor==3.3.3
如果由于某种原因(我强烈建议,因为他们最近有允许命令执行的XML-RPC漏洞),您无法升级您的主管,那么您需要创建一个shell脚本

start\u mongo.sh

#!/bin/bash
cd /home/user/socialhub/
exec docker-compose up

确保
chmod+x start\u mongo.sh
并将命令更改为
/path/to/start\u mongo.sh

我正在docker-compose.yml所在的~/socialhub执行主管。目录字段不是我想要输出的地方,或者执行的地方吗?它是命令开始的地方。或者您可以将命令更改为
command=docker-compose-f/home/user/socialhub/docker-compose.yml-up mongodb
我取消了目录字段,但仍然给出相同的错误[找不到命令'/usr/local/bin/docker-compose-up mongodb']您使用的是哪个版本的主管?问题在于docker-compose本身,主管找不到命令本身