add machine name to docker
This commit is contained in:
parent
e83adf4a15
commit
0e69a5d65a
2 changed files with 23 additions and 4 deletions
|
|
@ -13,17 +13,27 @@ def docker_ip():
|
|||
configuration = env.config
|
||||
|
||||
if configuration.docker.database.host == 'local':
|
||||
docker_cmd = 'docker-machine ip default'
|
||||
docker_cmd = 'docker-machine ip %s' % \
|
||||
configuration.docker.machine
|
||||
|
||||
return run(docker_cmd)
|
||||
|
||||
else:
|
||||
return configuration.docker.database.host
|
||||
|
||||
|
||||
def docker_run(cmd):
|
||||
from fabric.context_managers import prefix
|
||||
configuration = env.config
|
||||
|
||||
docker_eval = "eval $(docker-machine env default)"
|
||||
with prefix(docker_eval):
|
||||
if configuration.docker.machine:
|
||||
docker_eval = "eval $(docker-machine env %s)" % \
|
||||
configuration.docker.machine
|
||||
|
||||
with prefix(docker_eval):
|
||||
run(cmd)
|
||||
|
||||
else:
|
||||
run(cmd)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -863,7 +863,7 @@ def _init_docker(configuration, layout, config):
|
|||
project_branch=configuration.project.branch)
|
||||
|
||||
if 'name' in config['docker'] and config['docker']['name']:
|
||||
configuration.docker.name = config['docker']['name']
|
||||
configuration.docker.name = config['docker']['name']
|
||||
|
||||
#
|
||||
# host information
|
||||
|
|
@ -871,6 +871,15 @@ def _init_docker(configuration, layout, config):
|
|||
if 'host' in config['docker']:
|
||||
configuration.docker.host = config['docker']['host']
|
||||
|
||||
#
|
||||
# get machine name for docker-machine if exists
|
||||
|
||||
configuration.docker.machine = None
|
||||
|
||||
if 'machine' in config['docker']:
|
||||
configuration.docker.machine = config['docker']['machine']
|
||||
|
||||
#
|
||||
#
|
||||
# configuration info for docker database
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue