Docker cron not working

Hi,

my nextcloud instance is showing that cron is not working. I added a cron container but it is not working. Does anyone has an idea what is wrong with my setup?

version: '3' 

services:

  proxy:
    image: jwilder/nginx-proxy:alpine
    labels:
      - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"
    container_name: nextcloud-proxy
    networks:
      - nextcloud_network
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./proxy/conf.d:/etc/nginx/conf.d:rw
      - ./proxy/vhost.d:/etc/nginx/vhost.d:rw
      - ./proxy/html:/usr/share/nginx/html:rw
      - ./proxy/certs:/etc/nginx/certs:ro
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
    restart: unless-stopped
  
  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: nextcloud-letsencrypt
    depends_on:
      - proxy
    networks:
      - nextcloud_network
    volumes:
      - ./proxy/certs:/etc/nginx/certs:rw
      - ./proxy/vhost.d:/etc/nginx/vhost.d:rw
      - ./proxy/html:/usr/share/nginx/html:rw
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
    restart: unless-stopped

  db:
    image: mariadb
    container_name: nextcloud-mariadb
    networks:
      - nextcloud_network
    volumes:
      - db:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
    environment:
      - MYSQL_ROOT_PASSWORD=****
      - MYSQL_PASSWORD=****
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
    restart: unless-stopped
  
  app:
    image: nextcloud:latest
    container_name: nextcloud-app
    networks:
      - nextcloud_network
    depends_on:
      - letsencrypt
      - proxy
      - db
    volumes:
      - nextcloud:/var/www/html
      - ./app/config:/var/www/html/config
      - ./app/custom_apps:/var/www/html/custom_apps
      - ./app/data:/var/www/html/data
      - ./app/themes:/var/www/html/themes
      - /etc/localtime:/etc/localtime:ro
    environment:
      - VIRTUAL_HOST=zeetvtsit1fu0zv4.myfritz.net
      - LETSENCRYPT_HOST=zeetvtsit1fu0zv4.myfritz.net
      - LETSENCRYPT_EMAIL=thomas_pfannstiel@web.de
    restart: unless-stopped

  cron:
   image: nextcloud:apache
   container_name: nextcloud-cron
   networks:
     - nextcloud_network
   depends_on:
     - db
     - proxy
   volumes:
     - nextcloud:/var/www/html
   entrypoint: /cron.sh
   restart: unless-stopped

volumes:
  nextcloud:
  db:

networks:
  nextcloud_network:

Any hint is more than welcome.

Regards
Tombar

in your cron: container you should map all volumes you mapped into your app: container

additionally I would recommend to use same image (:latest is now same as :apache but who knows what happens in the future).

I would recommend against using :latest tag but rather use dedicated version flags

Hi wwe,

thanks for the tip. I changed the config and now it seems to work?

New config:

  cron:
   image: nextcloud:latest
   container_name: nextcloud-cron
   networks:
     - nextcloud_network
   depends_on:
     - db
     - proxy
   volumes:
     - nextcloud:/var/www/html
     - ./app/config:/var/www/html/config
     - ./app/custom_apps:/var/www/html/custom_apps
     - ./app/data:/var/www/html/data
     - ./app/themes:/var/www/html/themes
     - /etc/localtime:/etc/localtime:ro
   entrypoint: /cron.sh
   restart: always

As an alternative, you can call cron.php via docker exec from the host’s cron.