我试图在Docker容器上运行cron作业.我有一个正在运行的容器(Fedora 20).我还在容器中安装了cron包并显式运行了cron守护进程.我还检查了cron.deny文件是否为空,并且/ etc /目录下没有名为cron.allow的文件.
Whenever I tried to set the cronjob by using crontab -e or trying to list the cron job using crontab -l I am getting following error. bash-4.2# crontab -l You (root) are not allowed to access to (crontab) because of pam configuration. bash-4.2# crontab -e You (root) are not allowed to access to (crontab) because of pam configuration.
我还检查了它后面的/etc/pam.d/crond文件
bash-4.2 #vi /etc/pam.d/crond
# # The PAM configuration file for the cron daemon # # # No PAM authentication called, auth modules not needed account required pam_access.so account include password-auth session required pam_loginuid.so session include password-auth auth include password-auth
有人遇到过这个问题吗?如果是的话,请你指点一下吗?
提前致谢.
LXC容器不是虚拟机.你需要在前台明确地运行cron守护进程.更好的还是从Supervisor或runit等程序运行cron .
参考:Docker文档
传统上,Docker容器在启动时会运行单个进程,例如Apache守护程序或SSH服务器守护程序.通常,您希望在容器中运行多个进程.有许多方法可以实现这一点,从使用简单的Bash脚本作为容器的CMD指令的值到安装流程管理工具.
在这个例子中,我们将使用流程管理工具Supervisor来管理容器中的多个流程.使用Supervisor可以让我们更好地控制,管理和重启我们想要运行的流程.为了证明这一点,我们将安装和管理SSH守护程序和Apache守护程序.