Skip to content

LaggerIsME/docker-cleanup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Docker Cleanup Script for Linux

image image image Ansible Badge

What is this?

This is a Docker cleanup script for Linux, written in Bash. It deletes dead and exited containers, unused images, unused volumes and other docker trash.

Automated installation with Ansible

  1. Clone the repository:
git clone https://github.com/LaggerIsME/docker-cleanup.git
  1. Download and install the Ansible: https://docs.ansible.com/ansible/latest/installation_guide/installation_distros.html
  2. Move to the ~/docker-cleanup/ansible/ directory:
cd docker-cleanup/ansible/ 
  1. Copy the example.hosts to hosts:
cp example.hosts hosts
  1. Configure variables in .hosts file:
test_server_1 ansible_host="192.168.122.58" ansible_user="test_sudo_user" ansible_become_password="testpassword" ansible_password="testpassword"
test_server_2 ansible_host="192.168.122.59" ansible_user="test_sudo_user2" ansible_become_password="testpassword2" ansible_password="testpassword2"
  1. Activate ansible-playbook:
  • With default hosts file:
ansible-playbook install-script.yml -i hosts
  • With encrypted hosts file:
ansible-playbook --ask-vault-pass install-script.yml -i hosts

After all these actions, the script will clear your Linux every day at 01:00.

Manual installation

  1. Clone the repository:
git clone https://github.com/LaggerIsME/docker-cleanup.git
  1. Move to the ~/docker-cleanup/ directory:
cd docker-cleanup/
  1. Copy the docker-cleanup.sh to /root:
sudo cp docker-cleanup.sh /root/
  1. Make the docker-cleanup.sh executable:
sudo chmod +x /root/docker-cleanup.sh
  1. Enter in root user:
sudo -i -u root
  1. Enter in root's crontab with command:
crontab -e
  1. Add task in crontab (Example: Run script every day in 01:00):
0 1 * * * /root/docker-cleanup.sh

After all these actions, the script will clear your Linux every day at 01:00.

Logs

Script execution logs you can find in /var/log/docker-cleanup.log.

About

Docker Cleanup Script for Linux

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages