Created
August 29, 2017 16:30
-
-
Save noyb34/3e4b43045ad2c34e4612ea674474379f to your computer and use it in GitHub Desktop.
config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create /etc/systemd/system/docker-cleanup.timer with this content: | |
[Unit] | |
Description=Docker cleanup timer | |
[Timer] | |
OnUnitInactiveSec=12h | |
[Install] | |
WantedBy=timers.target | |
# And service file /etc/systemd/system/docker-cleanup.service: | |
[Unit] | |
Description=Docker cleanup | |
Requires=docker.service | |
After=docker.service | |
[Service] | |
Type=oneshot | |
WorkingDirectory=/tmp | |
User=root | |
Group=root | |
ExecStartPre=-/bin/bash -c 'docker ps -aqf status=exited | xargs docker rm -v' | |
ExecStartPre=-/bin/bash -c 'docker images -qf dangling=true | xargs docker rmi -f' | |
ExecStart=/bin/docker ps -af status=exited | |
[Install] | |
WantedBy=multi-user.target | |
# run systemctl enable docker-cleanup.timer for enabling the timer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment