'Run a one-off command on a service.
For example:
$ docker-compose run web python manage.py shell
By default, linked services will be started, unless they are already
running. If you do not want to start linked services, use
`docker-compose run --no-deps SERVICE COMMAND [ARGS...]`.
Usage: run [options] [-v VOLUME...] [-p PORT...] [-e KEY=VAL...] SERVICE [COMMAND] [ARGS...]
Options:
-d                    Detached mode: Run container in the background, print
new container name.
--name NAME           Assign a name to the container
--entrypoint CMD      Override the entrypoint of the image.
-e KEY=VAL            Set an environment variable (can be used multiple times)
-u, --user=""         Run as specified username or uid
--no-deps             Don\'t start linked services.
--rm                  Remove container after run. Ignored in detached mode.
-p, --publish=[]      Publish a container\'s port(s) to the host
--service-ports       Run command with the service\'s ports enabled and mapped
to the host.
-v, --volume=[]       Bind mount a volume (default [])
-T                    Disable pseudo-tty allocation. By default `docker-compose run`
allocates a TTY.
-w, --workdir=""      Working directory inside the container'

def run(self, options):

    service = self.project.get_service(options[u'SERVICE'])
    detach = options[u'-d']
    if (options[u'--publish'] and options[u'--service-ports']):
        raise UserError(u'Service    port    mapping    and    manual    port    mapping    can    not    be    used    together')
    if (options[u'COMMAND'] is not None):
        command = ([options[u'COMMAND']] + options[u'ARGS'])
    elif (options[u'--entrypoint'] is not None):
        command = []
    else:
        command = service.options.get(u'command')
    container_options = build_container_options(options, detach, command)
    run_one_off_container(container_options, self.project, service, options)
