Docker: Cronjob is not working

后端 未结 2 907
小蘑菇
小蘑菇 2020-12-21 10:59

I am trying to run cron job on Docker container. I have a running container (Fedora 20). I have also installed cron packages in container and explicitly run the cron daemon

2条回答
  •  攒了一身酷
    2020-12-21 11:16

    An LXC container is not a virtual machine. You'll need to explictly run the cron daemon in the foreground. Better still run cron from program like Supervisor or runit.

    Reference: Docker documentation

    Traditionally a Docker container runs a single process when it is launched, for example an Apache daemon or a SSH server daemon. Often though you want to run more than one process in a container. There are a number of ways you can achieve this ranging from using a simple Bash script as the value of your container's CMD instruction to installing a process management tool.

    In this example we're going to make use of the process management tool, Supervisor, to manage multiple processes in our container. Using Supervisor allows us to better control, manage, and restart the processes we want to run. To demonstrate this we're going to install and manage both an SSH daemon and an Apache daemon.

提交回复
热议问题