Skip to content


Browse files Browse the repository at this point in the history
Add docker host config support
Add ability to specify host configuration while creating a
docker latent worker.
  • Loading branch information
anish committed Mar 8, 2016
1 parent 605ed7b commit b977a0b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion master/buildbot/test/unit/
Expand Up @@ -61,7 +61,9 @@ def test_constructor_minimal(self):

def test_constructor_all_docker_parameters(self):
# Volumes have their own tests
bs = self.ConcreteWorker('bot', 'pass', 'unix:///var/run/docker.sock', 'worker_img', ['/bin/sh'], dockerfile="FROM ubuntu", version='1.9', tls=True)
bs = self.ConcreteWorker('bot', 'pass', 'unix:///var/run/docker.sock', 'worker_img', ['/bin/sh'],
dockerfile="FROM ubuntu", version='1.9', tls=True,
hostconfig={'network_mode': 'fake', 'dns': ['', '']})
self.assertEqual(bs.workername, 'bot')
self.assertEqual(bs.password, 'pass')
self.assertEqual(bs.image, 'worker_img')
Expand All @@ -70,6 +72,7 @@ def test_constructor_all_docker_parameters(self):
self.assertEqual(bs.volumes, [])
self.assertEqual(bs.binds, {})
self.assertEqual(bs.client_args, {'base_url': 'unix:///var/run/docker.sock', 'version': '1.9', 'tls': True})
self.assertEqual(bs.hostconfig, {'network_mode': 'fake', 'dns': ['', '']})

def test_volume_no_suffix(self):
bs = self.ConcreteWorker('bot', 'pass', 'tcp://1234:2375', 'worker', ['bin/bash'], volumes=['/src/webapp:/opt/webapp'])
Expand Down
6 changes: 4 additions & 2 deletions master/buildbot/worker/
Expand Up @@ -60,7 +60,7 @@ class DockerLatentWorker(AbstractLatentWorker):

def __init__(self, name, password, docker_host, image=None, command=None,
volumes=None, dockerfile=None, version=None, tls=None, followStartupLogs=False,
masterFQDN=None, hostconfig=None,

if not client:
Expand Down Expand Up @@ -99,6 +99,7 @@ def __init__(self, name, password, docker_host, image=None, command=None,
if masterFQDN is None:
masterFQDN = socket.getfqdn()
self.masterFQDN = masterFQDN
self.hostconfig = hostconfig or {}
# Prepare the parameters for the Docker Client object.
self.client_args = {'base_url': docker_host}
if version is not None:
Expand Down Expand Up @@ -156,7 +157,8 @@ def _thd_start_instance(self, image):
'Image "%s" not found on docker host.' % image

host_conf = docker_client.create_host_config(binds=self.binds)
self.hostconfig['binds'] = self.binds
host_conf = docker_client.create_host_config(**self.hostconfig)

instance = docker_client.create_container(
Expand Down
4 changes: 4 additions & 0 deletions master/docs/manual/cfg-workers-docker.rst
Expand Up @@ -216,6 +216,10 @@ In addition to the arguments available for any :ref:`Latent-Workers`, :class:`Do
Address of the master the worker should connect to. Use if you master machine does not have proper fqdn.
This value is passed to the docker image via environment variable ``BUILDMASTER``

Extra host configuration parameters passed as a dictionary used to create HostConfig object. See `docker-py's HostConfig documentation <>`_ for all the supported options.

Setting up Volumes

Expand Down
2 changes: 2 additions & 0 deletions master/docs/relnotes/index.rst
Expand Up @@ -22,11 +22,13 @@ Features

* :class:`GitPoller` now has a ``buildPushesWithNoCommits`` option to allow the rebuild of already known commits on new branches.
* Add GitLab authentication plugin for web UI. See :class:`buildbot.www.oauth2.GitLabAuth`.
* :class:`DockerLatentWorker` now has a ``hostconfig`` parameter that can be used to setup host configuration when creating a new container.


* Fix loading :class:`~buildbot.ldapuserinfo.LdapUserInfo` plugin and its documentation (:bug:`3371`).
* Fix deprecation warnings seen with docker-py >= 1.4 when passing arguments to ``docker_client.start()``.

Deprecations, Removals, and Non-Compatible Changes
Expand Down

0 comments on commit b977a0b

Please sign in to comment.