From all the pulled docker images remove keep only the N most recent images pulled
-
Clone repo
-
It is adviced to use a virtualenv
-
To setup a virtualenv
$ virtualenv --clear --always-copy VIRTUALENV_NAME
-
Install dependencies
$ VIRTUALENV_NAME/bin/pip install -r requirements.txt
-
Run it with the same privileges as the docker client
$ VIRTUALENV_NAME/bin/python di_cleaner.py --help
-
Another way
$ source VIRTUALENV_NAME/bin/activate $ ./di_cleaner --help
-
Run and show what images it is going to delete without deleting them
$ VIRTUALENV_NAME/bin/python di_cleaner.py --verbose --noop
-
Run with debug on
$ VIRTUALENV_NAME/bin/python di_cleaner.py --debug
-
Delete all images except the 10 most recent ones
$ VIRTUALENV_NAME/bin/python di_cleaner.py --images-to-keep 10
-
If you want to preserve the <none> images
$ VIRTUALENV_NAME/bin/python di_cleaner.py --keep-none-images
Start up your docker-machine. You need to setup the environment of your docker-machine in your shell
$ eval "$(docker-machine env default)"
Note, default is your virtual machine name
Now you can run all examples.
Run
$ VIRTUALENV_NAME/bin/python -m unittest discover
Build the image as ${IMAGE_NAME}
docker build -t ${IMAGE_NAME} .
Execute the program connected to the host socket
docker run -v /var/run/docker.sock:/var/run/docker.sock --rm -it ${IMAGE_NAME} --help