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.
- Clone the repository:
git clone https://github.com/LaggerIsME/docker-cleanup.git- Download and install the Ansible: https://docs.ansible.com/ansible/latest/installation_guide/installation_distros.html
- Move to the
~/docker-cleanup/ansible/directory:
cd docker-cleanup/ansible/ - Copy the
example.hoststohosts:
cp example.hosts hosts- Configure
variablesin.hostsfile:
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"- Activate
ansible-playbook:
- With default
hostsfile:
ansible-playbook install-script.yml -i hosts- With encrypted
hostsfile:
ansible-playbook --ask-vault-pass install-script.yml -i hostsAfter all these actions, the script will clear your Linux every day at 01:00.
- Clone the repository:
git clone https://github.com/LaggerIsME/docker-cleanup.git- Move to the
~/docker-cleanup/directory:
cd docker-cleanup/- Copy the
docker-cleanup.shto/root:
sudo cp docker-cleanup.sh /root/- Make the
docker-cleanup.shexecutable:
sudo chmod +x /root/docker-cleanup.sh- Enter in
rootuser:
sudo -i -u root- Enter in
root'scrontabwith command:
crontab -e- Add
taskincrontab(Example: Run script every day in 01:00):
0 1 * * * /root/docker-cleanup.shAfter all these actions, the script will clear your Linux every day at 01:00.
Script execution logs you can find in /var/log/docker-cleanup.log.