def output_compose(info, image_info):
    '''output as docker-compose format'''

    container = info['Name'][1:]

    conf = info['Config']
    hconf = info['HostConfig']

    compose = {}
    compose['container_name'] = str(container)
    compose['image'] = str(conf['Image'])

    # Volumes
    if 'Binds' in hconf and isinstance(hconf['Binds'], list):
        options = []
        for volume in hconf['Binds']:
            options.append(str(volume))
        if len(options) > 0:
            compose['volumes'] = options

    if 'PortBindings' in hconf and isinstance(hconf['PortBindings'], dict):
        options = []
        for binding, hosts in hconf['PortBindings'].items():
            for host in hosts:
                portbinding = ''
                if 'HostIp' in host and host['HostIp']:
                    portbinding += host['HostIp'] + ':'
                if 'HostPort' in host and host['HostPort']:
                    portbinding += host['HostPort'] + ':'
                portbinding += binding
                options.append(str(portbinding))
        if len(options) > 0:
            compose['ports'] = options

    # Devices
    if 'Devices' in hconf and isinstance(hconf['Devices'], list):
        options = []
        for device in hconf['Devices']:
            options.append(str(device))
        if len(options) > 0:
            compose['devices'] = options

    # RestartPolicy
    if 'RestartPolicy' in hconf and hconf['RestartPolicy']['Name']:
        policy = hconf['RestartPolicy']['Name']
        if hconf['RestartPolicy']['MaximumRetryCount'] > 0:
            policy += ':' + str(hconf['RestartPolicy']['MaximumRetryCount'])
        compose['restart'] = str(policy)

    # Privileged
    if hconf['Privileged']:
        compose['privileged'] = True

    # Env
    if isinstance(conf['Env'], list) and len(conf['Env']) > 0:
        options = []
        for env in conf['Env']:
            if env not in image_info['Config']['Env']:
                options.append(str(env))
        if len(options) > 0:
            compose['environment'] = options

    # DNS
    if 'Dns' in hconf and isinstance(hconf['Dns'], list):
        options = []
        for dns in hconf['Dns']:
            options.append(str(dns))
        if len(options) > 0:
            compose['dns'] = options

    # ExposedPorts
    if 'ExposedPorts' in conf and isinstance(conf['ExposedPorts'], dict):
        options = []
        for port, _ in conf['ExposedPorts'].items():
            if ('ExposedPorts' not in image_info['Config'] or
                    port not in image_info['Config']['ExposedPorts']):
                options.append(str(port))
        if len(options) > 0:
            compose['expose'] = options

    # User
    if conf['User'] and image_info['Config']['User'] != conf['User']:
        compose['user'] = str(conf['User'])

    # WorkingDir
    if image_info['Config']['WorkingDir'] != conf['WorkingDir']:
        compose['working_dir'] = str(conf['WorkingDir'])

    # EntryPoint
    if conf['Entrypoint'] != image_info['Config']['Entrypoint']:
        if isinstance(conf['Entrypoint'], list):
            entry = []
            for entry_item in conf['Entrypoint']:
                entry.append(str(entry_item))
            if len(entry) > 0:
                compose['entrypoint'] = entry
        elif isinstance(conf['Entrypoint'], str):
            compose['entrypoint'] = str(conf['Entrypoint'])

    name = str(info['Name'][1:])
    print(yaml.dump({name:compose}, encoding='utf-8', default_flow_style=False))
output as docker-compose format