Friday, February 18, 2022

[SOLVED] Cron job doesn't work (with docker command)

Issue

I have some commands I want to run every day in my crontab:

5 0 * * * docker image prune
5 0 * * * docker image prune -a
5 0 * * * docker container prune

They don't seem to be really working as my server memory keeps decreasing with the amount of images and containers stocked. I know those commands takes a manual intervention to accept with y, I tried the docker image prune -y in my terminal but it is not getting recognized.

Any tip? Thanks!


Solution

Use the -f flag:

docker image prune -a -f

Help text:

Usage:  docker image prune [OPTIONS]

Remove unused images

Options:
  -a, --all     Remove all unused images, not just dangling ones
  -f, --force   Do not prompt for confirmation
      --help    Print usage


Answered By - rndmh3ro
Answer Checked By - Mildred Charles (WPSolving Admin)