Skip to content

Commit

Permalink
Merge pull request #34 from phiros/add_volume_host_dir_binds
Browse files Browse the repository at this point in the history
allow host dir to volume bindings
  • Loading branch information
Ilya Radchenko committed Jun 27, 2015
2 parents 0afea58 + 36675c6 commit 010331e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions config/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ <h3>Docker Runner</h3>
<input ng-model="config.docker_host" placeholder="Docker remote host (defaults to env var DOCKER_HOST)" class="input-block-level input-xxlarge" type="text">
<input ng-model="config.image" placeholder="Docker image to use. Default: strider/strider-docker-slave" class="input-block-level input-xxlarge" type="text">
<input ng-model="config.dns" placeholder="comma separated list of dns servers, default: 8.8.8.8" class="input-block-level input-xxlarge" type="text">
<p>
Use the following to bind host directories to volumes in a docker container:
</p>
<input ng-model="config.docker_volumeBinds" placeholder="comma seperated list of bindings e.g.: /some/host/dir:/in_container:rw,/other:/foo:rw, Default: ''" class="input-block-level input-xxlarge" type="text">
<label class="checkbox">
<input type="checkbox" ng-model="config.privileged">
Should the image run in privileged mode? WARNING: Don't run insecure code in privileged mode.
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
port: Number,
socketPath: String,
dns: String,
docker_host: String
docker_host: String,
docker_volumeBinds: String
}
}
3 changes: 2 additions & 1 deletion lib/create-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function create (createOptions, docker, config, done) {

// start, and wait for it to be done
container.start({
Binds: config.docker_volumeBinds,
Privileged: config.privileged,
PublishAllPorts: config.publishPorts,
Dns: config.dns,
Expand Down Expand Up @@ -134,4 +135,4 @@ module.exports = function (createOptions, docker, config, done) {
create(createOptions, docker, config, done)
}
]);
}
}
8 changes: 8 additions & 0 deletions lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ module.exports = function (job, provider, plugins, config, next) {
if (slaveConfig.dns && slaveConfig.dns.length > 6) {
slaveConfig.dns = slaveConfig.dns.split(",")
}
if (slaveConfig.docker_volumeBinds && slaveConfig.docker_volumeBinds.indexOf(',') > -1) {
slaveConfig.docker_volumeBinds = slaveConfig
.docker_volumeBinds
.split(",")
.map(function (volBinding) {
return volBinding.trim();
});
}
config.io.emit('job.status.command.comment', job._id, {
comment: 'Creating docker container from ' + slaveConfig.image,
plugin: 'docker',
Expand Down

0 comments on commit 010331e

Please sign in to comment.