Mount volumes

This commit is contained in:
Aanand Prasad 2013-12-19 15:53:39 +00:00
parent d6db049b42
commit 818728b825
1 changed files with 12 additions and 0 deletions

View File

@ -1,6 +1,7 @@
from docker.client import APIError from docker.client import APIError
import logging import logging
import re import re
import os
import sys import sys
from .container import Container from .container import Container
@ -84,10 +85,18 @@ class Service(object):
else: else:
port_bindings[int(port)] = None port_bindings[int(port)] = None
volume_bindings = {}
if options.get('volumes', None) is not None:
for volume in options['volumes']:
external_dir, internal_dir = volume.split(':')
volume_bindings[os.path.abspath(external_dir)] = internal_dir
log.info("Starting %s..." % container.name) log.info("Starting %s..." % container.name)
container.start( container.start(
links=self._get_links(), links=self._get_links(),
port_bindings=port_bindings, port_bindings=port_bindings,
binds=volume_bindings,
) )
return container return container
@ -125,6 +134,9 @@ class Service(object):
if 'ports' in container_options: if 'ports' in container_options:
container_options['ports'] = [unicode(p).split(':')[0] for p in container_options['ports']] container_options['ports'] = [unicode(p).split(':')[0] for p in container_options['ports']]
if 'volumes' in container_options:
container_options['volumes'] = dict((v.split(':')[1], {}) for v in container_options['volumes'])
if 'build' in self.options: if 'build' in self.options:
container_options['image'] = self.build() container_options['image'] = self.build()