from datetime import datetime


def to_datetime(s):
    """Parse a datetime string from docker logs to a Python datetime object

    Args:
        s (str): Docker datetime string

    Returns:
        datetime: Python datetime object
    """    
    s = s.split(' ')[0]
    s = s.replace('T', ' ')
    s = s.replace('Z', '')
    s = s[:s.find('.') + 7]
    return datetime.strptime(s, '%Y-%m-%d %H:%M:%S.%f')