Uname:Linux mail.sarafai.ru 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64

403WebShell
403Webshell
Server IP : 82.148.16.210  /  Your IP : 216.73.216.19
Web Server : nginx/1.29.5
System : Linux mail.sarafai.ru 6.1.0-43-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.162-1 (2026-02-08) x86_64
User : root ( 0)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/share/gitlab-runner/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/gitlab-runner/clear-docker-cache
#!/usr/bin/env bash
# http://redsymbol.net/articles/unofficial-bash-strict-mode/

#########################################################################################
#  SCRIPT: clear-docker-cache.sh
#  Description: Used to cleanup unused docker containers and volumes
######################################################################################
IFS=$'\n\t'
set -euo pipefail

if ! [ -x "$(command -v docker)" ]; then
  echo -e "INFO: Docker installation not found, skipping clear-docker-cache"
  exit 0
fi

DOCKER_API_VERSION=$(docker version --format '{{.Client.APIVersion}}')
DOCKER_CLIENT_VERSION=$(docker version --format '{{.Client.Version}}')
DOCKER_CLIENT_VERSION="${DOCKER_CLIENT_VERSION%%-*}" # strip -whatever, so 23.0.0-rd becomes 23.0.0
REQUIRED_DOCKER_API_VERSION=1.25
FILTER_FLAG="${FILTER_FLAG:-label=com.gitlab.gitlab-runner.managed=true}"

usage() {
  echo -e "\nUsage: $0 prune-volumes|prune|space|help\n"
  echo -e "\tprune-volumes    Remove all unused containers (both dangling and unreferenced) and volumes"
  echo -e "\tprune            Remove all unused containers (both dangling and unreferenced)"
  echo -e "\tspace            Show docker disk usage"
  echo -e "\thelp             Show usage"
  exit 1
}

if awk "BEGIN {exit !(\"$DOCKER_API_VERSION\" < \"$REQUIRED_DOCKER_API_VERSION\")}"; then
  echo -e "ERROR: Your current API version is lower than ${REQUIRED_DOCKER_API_VERSION}. The client and daemon API must both be at least ${REQUIRED_DOCKER_API_VERSION}+ to run these commands. Kindly upgrade your docker version."
  exit 1
fi

COMMAND="${1:-prune-volumes}"

case "$COMMAND" in

  prune)

    echo -e "\nCheck and remove all unused containers (both dangling and unreferenced)"
    echo -e "-----------------------------------------------------------------------"

    if awk "BEGIN {exit !(\"$DOCKER_CLIENT_VERSION\" < \"17.06.1\")}"; then
      # The docker system prune command without pruning volumes does not exist before 17.06.1, so we need to use docker rm
      CONTAINERS=$(docker ps -a -q \
                  --filter=status=exited \
                  --filter=status=dead \
                  --filter="$FILTER_FLAG")

      if [ -n "${CONTAINERS}" ]; then
        docker rm "${CONTAINERS}"
      fi
    else
      docker system prune -af --filter "$FILTER_FLAG"
    fi

    exit 0
    ;;

  space)

    echo -e "\nShow docker disk usage"
    echo -e "----------------------"
    docker system df

    exit 0
    ;;

  help)

    usage
    ;;

  prune-volumes)

    echo -e "\nCheck and remove all unused containers (both dangling and unreferenced) including volumes."
    echo -e "------------------------------------------------------------------------------------------"

    if awk "BEGIN {exit !(\"$DOCKER_CLIENT_VERSION\" < \"17.04.0\")}"; then
      # Prior to 17.04, there was no filter flag for `docker system prune`, so we fallback to `docker rm`
      CONTAINERS=$(docker ps -a -q \
                  --filter=status=exited \
                  --filter=status=dead \
                  --filter="$FILTER_FLAG")

      if [ -n "${CONTAINERS}" ]; then
        docker rm -v "${CONTAINERS}"
      fi

      exit 0
    elif awk "BEGIN {exit !(\"$DOCKER_CLIENT_VERSION\" < \"17.05.0\")}"; then
      # Prior to 17.05, `docker system prune` would also cleanup volumes
      docker system prune -af --filter "$FILTER_FLAG"
    elif awk "BEGIN {exit !(\"$DOCKER_CLIENT_VERSION\" < \"23.0.0\")}"; then
      # Prior to 23.0, `docker volume prune` didn't support --all
      docker system prune -af --filter "$FILTER_FLAG"
      docker volume prune -f --filter "$FILTER_FLAG"
    else
      docker system prune -af --filter "$FILTER_FLAG"
      docker volume prune -af --filter "$FILTER_FLAG"
    fi

    exit 0
    ;;

esac

Youez - 2016 - github.com/yon3zu
LinuXploit