@contextmanager
def dockpulp_config(docker_registry, **kwargs):

    env = 'sync'
    template = """
[registries]
{sync}

[filers]
{sync}

[pulps]
{sync}
"""
    sync = '{env} = {url}'.format(env=env, url=docker_registry)
    with NamedTemporaryFile('wt', **kwargs) as config:
        config.write(template.format(sync=sync))
        config.flush()
        config.env = env
        yield config
Temporary dockpulp config pointing to the docker v2 registry
dataset/ETHPy150Open projectatomic/atomic-reactor/atomic_reactor/plugins/post_pulp_sync.py/dockpulp_config