Skip to content

Commit

Permalink
WIP: Add support for build time volumes
Browse files Browse the repository at this point in the history
Resolves docker#1498

Signed-off-by: Daniel Beyer <ymc-dabe@vcs.ymc.ch>
  • Loading branch information
ymc-dabe committed Mar 1, 2018
1 parent 9b8e022 commit 86481bb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion docker/api/build.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import logging
import os
import six

from .. import auth
from .. import constants
Expand All @@ -18,7 +19,7 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
forcerm=False, dockerfile=None, container_limits=None,
decode=False, buildargs=None, gzip=False, shmsize=None,
labels=None, cache_from=None, target=None, network_mode=None,
squash=None, extra_hosts=None, platform=None):
squash=None, extra_hosts=None, platform=None, volumes=None):
"""
Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
needs to be set. ``path`` can be a local path (to a directory
Expand Down Expand Up @@ -100,6 +101,8 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
extra_hosts (dict): Extra hosts to add to /etc/hosts in building
containers, as a mapping of hostname to IP address.
platform (str): Platform in the format ``os[/arch[/variant]]``
volumes (str or list): List of bind mounts or named volumes to
make available during the build
Returns:
A generator for the build output.
Expand Down Expand Up @@ -231,6 +234,11 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
)
params['platform'] = platform

if volumes is not None:
if isinstance(volumes, six.string_types):
volumes = [volumes, ]
params.update({'volumes': json.dumps(volumes)})

if context is not None:
headers = {'Content-Type': 'application/tar'}
if encoding:
Expand Down

0 comments on commit 86481bb

Please sign in to comment.