(old, new, self_name=None)
return properties
Store object for spawning new container in place of the one with outdated image
Store object for spawning new container in place of the one with outdated image
Store object for spawning new container in place of the one with outdated image
def set_properties(old, new, self_name=None):
    """Store object for spawning new container in place of the one with outdated image"""
    properties = {
        'name': self_name if self_name else old.name,
        'hostname': old.attrs['Config']['Hostname'],
        'user': old.attrs['Config']['User'],
        'detach': True,
        'domainname': old.attrs['Config']['Domainname'],
        'tty': old.attrs['Config']['Tty'],
        'ports': None if not old.attrs['Config'].get('ExposedPorts') else [
            (p.split('/')[0], p.split('/')[1]) for p in old.attrs['Config']['ExposedPorts'].keys()
        ],
        'volumes': None if not old.attrs['Config'].get('Volumes') else [
            v for v in old.attrs['Config']['Volumes'].keys()
        ],
        'working_dir': old.attrs['Config']['WorkingDir'],
        'image': new.tags[0],
        'command': old.attrs['Config']['Cmd'],
        'host_config': old.attrs['HostConfig'],
        'labels': old.attrs['Config']['Labels'],
        'entrypoint': old.attrs['Config']['Entrypoint'],
        'environment': old.attrs['Config']['Env'],
        'healthcheck': old.attrs['Config'].get('Healthcheck', None)
    }

    return properties
def set_properties ( old , new , self_name = None ) : properties = { 'name' : self_name if self_name else old . name , 'hostname' : old . attrs [ 'Config' ] [ 'Hostname' ] , 'user' : old . attrs [ 'Config' ] [ 'User' ] , 'detach' : True , 'domainname' : old . attrs [ 'Config' ] [ 'Domainname' ] , 'tty' : old . attrs [ 'Config' ] [ 'Tty' ] , 'ports' : None if not old . attrs [ 'Config' ] . get ( 'ExposedPorts' ) else [ ( p . split ( '/' ) [ 0 ] , p . split ( '/' ) [ 1 ] ) for p in old . attrs [ 'Config' ] [ 'ExposedPorts' ] . keys ( ) ] , 'volumes' : None if not old . attrs [ 'Config' ] . get ( 'Volumes' ) else [ v for v in old . attrs [ 'Config' ] [ 'Volumes' ] . keys ( ) ] , 'working_dir' : old . attrs [ 'Config' ] [ 'WorkingDir' ] , 'image' : new . tags [ 0 ] , 'command' : old . attrs [ 'Config' ] [ 'Cmd' ] , 'host_config' : old . attrs [ 'HostConfig' ] , 'labels' : old . attrs [ 'Config' ] [ 'Labels' ] , 'entrypoint' : old . attrs [ 'Config' ] [ 'Entrypoint' ] , 'environment' : old . attrs [ 'Config' ] [ 'Env' ] , 'healthcheck' : old . attrs [ 'Config' ] . get ( 'Healthcheck' , None ) } return properties