You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
780 B
Python

#!/usr/bin/python3
"""Check Docker images for security/distro updates. Assumes DNF."""
from __future__ import division, print_function
import docker
import subprocess
c = docker.APIClient(base_url='unix://var/run/docker.sock')
for container in c.containers():
name = container['Names'][0]
id_ = container['Id']
image_id = c.inspect_container(id_)['Image']
print('-' * 75)
print('Container: {}'.format(name))
print('Image: {} '.format(image_id))
# Not using the API here for simplicity (for now)
output = subprocess.check_output([
'docker', 'run', '-t', '--rm',
image_id,
'/bin/bash', '-c',
'dnf -q check-update;' +
'if [ $? == 100 ]; then echo "Updates available"; fi'
])
print(output.decode())