Docker: Cronjob is not working

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.
I have also checked cron.deny file it is empty and there is no file called cron.allow under /etc/ directory.

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.

I also checked the /etc/pam.d/crond file it has following entry

  • ECS Docker Container get env variable running cron
  • When to use -type d-exec chmod 750 / 640 in docker
  • Executing a shell script within docker with RUN command
  • Docker run/star/exec?
  • How do I enter this dockerfile / nginx container?
  • How to wait for postgres startup in ENTRYPOINT?
  • 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
    

    Has any one faced this issue? If yes could you please suggest me some pointer on this?

    thanks in advance.

  • Is it possible to configure Docker to pull from my GitHub repo?
  • Behat Mink file upload not finding file on submit
  • cannot create JDBC datasource named transactional_DS while implementing Multi-instance in moqui using docker
  • Get composer (php dependency manager) to run on a docker image build
  • Deploying docker-compose containers
  • Restart Kubernetes pod when change happens on another
  • 2 Solutions collect form web for “Docker: Cronjob is not working”

    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.

    You can do:

    ENTRYPOINT cron -f

    although remember that you can only have one ENTRYPOINT.

    From the docs:

    There can only be one ENTRYPOINT in a Dockerfile. If you have more
    than one ENTRYPOINT, then only the last one in the Dockerfile will
    have an effect.

    An ENTRYPOINT helps you to configure a container that you can run as
    an executable. That is, when you specify an ENTRYPOINT, then the whole
    container runs as if it was just that executable.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.