在不同主机上运行cron的问题 [英] Issues running cron in Docker on different hosts

查看:158
本文介绍了在不同主机上运行cron的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图获取一个docker容器运行来管理我的cronjobs

Im trying to get a docker container running to mange my cronjobs

我运行一个非常简单的cron作为测试在docker容器使用centOS 6.5 base

im running a very simple cron as a test in a docker container using centOS 6.5 base

* * * * * /bin/echo "it works!" >> test.log

如果容器在CoreOS主机上运行,​​它可以正常工作,但是如果我运行容器在ubuntu 13.10主机上不执行cron。 (我虽然主机没有影响在容器中运行)

it works fine if the container is running on CoreOS host, however if I run the container on a ubuntu 13.10 host the cron is not executed. (I though the host did not effect what was running in the container)

两个主机都在运行docker 0.8

both hosts are running docker 0.8

推荐答案

简短回答

将此行添加到dockerfile

add this line to your dockerfile

RUN sed -i '/session    required   pam_loginuid.so/c\#session    required   pam_loginuid.so' /etc/pam.d/crond

长回答

CoreOS& Unbutu。这反过来导致pam安全问题。

from what I understand issue is related to differences in the kernal between CoreOS & Unbutu. this in-turn causes a pam security issue.

这是我们首先需要为cron打开日志记录(因为我们在docker正常启动不执行)。运行

to figure it our first needed to turn on logging for cron (since we are in docker normal startup is not executed). run

service rsyslog start
service crond restart

cron日志出现此错误(位于/ var / log / cron)

the cron log had this error (located here /var/log/cron)

FAILED to open PAM security session (Cannot make/remove an entry for the specified session)

所以我看了安全日志,它有这个错误(位于/ var / log / secure)

so then I took a look at the security log, and it had this error (located here /var/log/secure)

pam_loginuid(crond:session): set_loginuid failed

一些更多的搜索,发现我需要修改我的pam cond config(在这里找到/etc/pam.d/crond)
编辑此文件并注释掉以下行

some more googling and found I needed to modify my pam cond config (found here /etc/pam.d/crond) edit this file and comment out the following line

#session    required   pam_loginuid.so

重新启动crond,所有应该都很好

restart crond and all should be good

这篇关于在不同主机上运行cron的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆