'Run a service like a detached container'

def run_in_container(self, command, image=None, **kwopts):

    kwopts['replicas'] = '1'
    kwopts['restart_condition'] = 'none'
    if kwopts.get('publish_all_ports', False):
        if (kwopts.get('publish_port_random', False) or kwopts.get('ports', False)):
            del kwopts['publish_all_ports']
        else:
            raise ContainerRunError('Publishing    all    ports    is    not    supported    in    Docker    swarm    mode,    use    `publish_port_random`    or    `ports`', image=image, command=command)
    if (not kwopts.get('detach', True)):
        raise ContainerRunError('Running    attached    containers    is    not    supported    in    Docker    swarm    mode', image=image, command=command)
    elif kwopts.get('detach', None):
        del kwopts['detach']
    if kwopts.get('volumes', None):
        if self._conf.ignore_volumes:
            log.warning(("'volumes'    kwopt    is    set    and    not    supported    in    Docker    swarm    mode,    volumes    will    not    be    passed    (set    'ignore_volumes:    False'    in    containers    config    to    fail    instead):    %s" % kwopts['volumes']))
            del kwopts['volumes']
        else:
            raise ContainerRunError(("'volumes'    kwopt    is    set    and    not    supported    in    Docker    swarm    mode    (set    'ignore_volumes:    True'    in    containers    config    to    warn    instead):    %s" % kwopts['volumes']), image=image, command=command)
    service = self.service_create(command, image=image, **kwopts)
    self._run_swarm_manager()
    return service
