@_ensure_exists
def copy_to(name, source, dest, overwrite=False, makedirs=False):
    path = source
    try:
        if source.startswith('salt://'):
            cached_source = __salt__['cp.cache_file'](source)
            if not cached_source:
                raise CommandExecutionError(
                    'Unable to cache {0}'.format(source)
                )
            path = cached_source
    except AttributeError:
        raise SaltInvocationError('Invalid source file {0}'.format(source))

    if _sd_version() >= 219:
        # TODO: Use machinectl copy-to
        pass
    return __salt__['container_resource.copy_to'](
        name,
        path,
        dest,
        container_type=__virtualname__,
        exec_driver=EXEC_DRIVER,
        overwrite=overwrite,
        makedirs=makedirs)
Copy a file from the host into a container
dataset/ETHPy150Open saltstack/salt/salt/modules/nspawn.py/copy_to