'Parse the `ports` string into a port bindings dict for the `start_container` call.'

def get_port_bindings(self, ports):

    binds = {}
    for port in ports:
        parts = str(port).split(':')
        container_port = parts[(-1)]
        if ('/' not in container_port):
            container_port = int(parts[(-1)])
        p_len = len(parts)
        if (p_len == 1):
            bind = ('0.0.0.0',)
        elif (p_len == 2):
            bind = ('0.0.0.0', int(parts[0]))
        elif (p_len == 3):
            bind = ((parts[0], int(parts[1])) if parts[1] else (parts[0],))
        if (container_port in binds):
            old_bind = binds[container_port]
            if isinstance(old_bind, list):
                old_bind.append(bind)
            else:
                binds[container_port] = [binds[container_port], bind]
        else:
            binds[container_port] = bind
    return binds
