from data.database import Image from app import app import json store = app.config['STORAGE'] for image in Image.select(): if image.command == None: image_json_path = store.image_json_path(image.repository.namespace, image.repository.name, image.docker_image_id) if store.exists(image_json_path): data = json.loads(store.get_content(image_json_path)) command_list = data.get('container_config', {}).get('Cmd', None) command = json.dumps(command_list) if command_list else None print 'Setting command to: %s' % command image.command = command image.save()