克隆是无法运行我的命令,即使它适用于我(在docker集装箱内)

我有一个Django项目的Docker容器(带有postgres数据库),我创build了一个小脚本,以便每24小时执行一次自动备份。 在我的cron文件中,我有以下几点:

SHELL=/bin/bash * * * * * whoami &>>/tmp/dbg.log * * * * * cd /home/projects/my-project/ && . env/bin/activate && scripts/sh/auto_backup.sh &>>/tmp/cron_debug.log 

编辑

正在运行的脚本(auto_backup)看起来像这样:

 #!/bin/bash today=$(date +"%d_%m_%Y") ./manage.py dumpdata --indent=4 > backups/backup_${today}.json && echo "Backup complete" 

完成编辑

如果我自己运行cron命令,一切正常。 但是,如果我让cron做到这一点,我总是得到以下错误:

 CommandError: Unable to serialize database: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? 

我正在Docker容器中运行这个,在我的本地机器上一切运行顺利。 postgres数据库确实在另一个容器中(在另一个容器中),但是当我手动运行该命令时,这似乎不是问题。 另外,我查了一下, whoami总是返回root,所以似乎没有权限问题。