def strip_config()

in docker/util/config_stripper.py [0:0]


def strip_config(path, new_diff_ids):
    with open(path, 'r') as f:
        config = json.load(f)
    config['created'] = _TIMESTAMP
    config['rootfs']['diff_ids'] = new_diff_ids

    # Base container info is not required and changes every build, so delete it.
    if 'container' in config:
      del config['container']
    if ('config' in config and
        'Hostname' in config['config']):
      del config['config']['Hostname']
    if ('container_config' in config and
        'Hostname' in config['container_config']):
      del config['container_config']['Hostname']
    if 'docker_version' in config:
      del config['docker_version']
    for entry in config['history']:
        entry['created'] = _TIMESTAMP

    config_str = json.dumps(config, sort_keys=True)
    with open(path, 'w') as f:
        f.write(config_str)

    # Calculate the new file path
    sha = hashlib.sha256(config_str.encode("utf-8")).hexdigest()
    new_path = 'sha256:%s' % sha
    os.rename(path, os.path.join(os.path.dirname(path), new_path))
    return new_path