mirror of
https://github.com/docker/compose.git
synced 2025-07-26 07:04:32 +02:00
Spike: Start linked containers on fig run
by default
Signed-off-by: Chris Corbyn <chris@w3style.co.uk>
This commit is contained in:
parent
b081077f2b
commit
b672861ffd
@ -202,27 +202,29 @@ class TopLevelCommand(Command):
|
|||||||
|
|
||||||
$ fig run web python manage.py shell
|
$ fig run web python manage.py shell
|
||||||
|
|
||||||
Note that by default this will not start any services that the
|
By default, linked services will be started, unless they are already
|
||||||
command's service links to. So if, for example, your one-off command
|
running. If you do not want to start linked services, use
|
||||||
talks to your database, you will need to either run `fig up -d db`
|
`fig run --no-links SERVICE COMMAND [ARGS...]`.
|
||||||
first, or use `fig run --up SERVICE COMMAND [ARGS...]`.
|
|
||||||
|
|
||||||
Usage: run [options] SERVICE COMMAND [ARGS...]
|
Usage: run [options] SERVICE COMMAND [ARGS...]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-d Detached mode: Run container in the background, print new
|
-d Detached mode: Run container in the background, print
|
||||||
container name
|
new container name.
|
||||||
-T Disable pseudo-tty allocation. By default `fig run`
|
-T Disable pseudo-tty allocation. By default `fig run`
|
||||||
allocates a TTY.
|
allocates a TTY.
|
||||||
--rm Remove container after run. Ignored in detached mode.
|
--rm Remove container after run. Ignored in detached mode.
|
||||||
--up Also start services that the command's service links to
|
--no-links Don't start linked services.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if options['--up']:
|
|
||||||
self.up({'-d': True, 'SERVICE': None})
|
|
||||||
|
|
||||||
service = self.project.get_service(options['SERVICE'])
|
service = self.project.get_service(options['SERVICE'])
|
||||||
|
|
||||||
|
if not options['--no-links']:
|
||||||
|
self.up({
|
||||||
|
'-d': True,
|
||||||
|
'SERVICE': self._get_linked_service_names(service)
|
||||||
|
})
|
||||||
|
|
||||||
tty = True
|
tty = True
|
||||||
if options['-d'] or options['-T'] or not sys.stdin.isatty():
|
if options['-d'] or options['-T'] or not sys.stdin.isatty():
|
||||||
tty = False
|
tty = False
|
||||||
@ -338,5 +340,8 @@ class TopLevelCommand(Command):
|
|||||||
raw=raw,
|
raw=raw,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _get_linked_service_names(self, service):
|
||||||
|
return [s.name for (s, _) in service.links]
|
||||||
|
|
||||||
def list_containers(containers):
|
def list_containers(containers):
|
||||||
return ", ".join(c.name for c in containers)
|
return ", ".join(c.name for c in containers)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user