Docker allows mounting host directories as a data volumes from docker run -v command line options, but can't specify that when running with nova-docker

Registered by Yufen Kuo on 2016-06-22

Docker allows users to specify data volumes using the -v command line option when running docker containers
docker run -v /Users/<path>:/<container path>

But when launching docker instances from nova-docker, there is no where to pass in the -v command line option.

Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
Yufen Kuo
Direction:
Needs approval
Assignee:
None
Definition:
New
Series goal:
Proposed for trunk
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

1) in driver.py, there is already oslo_config options defined for docker group settings. We could add additional option to allow users specify docker volumes and pass the settings to docker-py to allow mounting volumes in docker containers. But this setting is generic across all docker images.

The option can be set in nova.conf file as:
[docker]
docker_volumes=/etc/resolv.conf:/etc/resolv.conf

and the patch to add the option (against stable/mitaka branch):
diff --git a/novadocker/virt/docker/driver.py b/novadocker/virt/docker/driver.py
index 18e52ee..6240967 100644
--- a/novadocker/virt/docker/driver.py
+++ b/novadocker/virt/docker/driver.py
@@ -93,6 +93,9 @@ docker_opts = [
                help='Shared directory where glance images located. If '
                     'specified, docker will try to load the image from '
                     'the shared directory by image ID.'),
+ cfg.StrOpt('docker_volumes',
+ default='',
+ help='Specify docker volumes to mount'),
     cfg.BoolOpt('privileged',
                 default=False,
                 help='Set true can own all root privileges in a container.'),
@@ -524,6 +527,9 @@ class DockerDriver(driver.ComputeDriver):
         if (image_meta is not None and
                 image_meta.properties.get("os_command_line") is not None):
             args['command'] = image_meta.properties.get("os_command_line")
+ docker_volumes = CONF.docker.docker_volumes
+ if (docker_volumes):
+ args['binds'] = docker_volumes.split(",")

         if 'metadata' in instance:
             args['environment'] = nova_utils.instance_meta(instance)

2) If users want to specify per image settings, then we will need to add a new property in nova (ImageMetaProps's attribute) in order to be able to retrieve the value.
It will work as the glance image property "os_command_line",
glance image-update --property os_command_line='/usr/sbin/sshd -D' $IMAGE_ID

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.