diff --git a/config/worker.example.docker.yml b/config/worker.example.docker.yml new file mode 100644 index 00000000..9312b37a --- /dev/null +++ b/config/worker.example.docker.yml @@ -0,0 +1,25 @@ +env: linux +linux: + amqp: + host: host + port: port + username: username + password: password + virtual_host: vhost + vms: + provider: blue_box + count: 3 + docker: + cmd: + username: travis + enable_cpuset: true + image_name: cip + default_image: cip:latest + private_key_path: /path/to/ssh/id_rsa + api: + host: localhost + port: 4234 + memory: 4 + expose_ports: + language_mappings: + haskell: jvm diff --git a/lib/travis/worker/virtual_machine/docker.rb b/lib/travis/worker/virtual_machine/docker.rb index b1c41249..b55769a0 100644 --- a/lib/travis/worker/virtual_machine/docker.rb +++ b/lib/travis/worker/virtual_machine/docker.rb @@ -46,13 +46,14 @@ def create_server(opts = {}) def create_container(image_id) create_options = { - 'Cmd' => ['/sbin/init'], 'Image' => image_id, 'Memory' => (1024 * 1024 * 1024 * (docker_config.memory || 4)), - 'Cpuset' => cpu_set, 'Hostname' => short_hostname, } + create_options['Cpuset'] = cpu_set if docker_config.enable_cpuset + create_options['Cmd'] = docker_config.cmd if docker_config.cmd + # Allow for opting out of 'Domainname' as this results in lxc-start # explosions on docker 1.3.2 (and maybe others?) create_options['Domainname'] = domainname unless docker_config.omit_domainname @@ -117,7 +118,7 @@ def session @session ||= Ssh::Session.new(name, :host => ssh_host, :port => ssh_port, - :username => 'travis', + :username => docker_config.username, :private_key_path => docker_config.private_key_path, :buffer => Travis::Worker.config.shell.buffer, :timeouts => Travis::Worker.config.timeouts @@ -157,7 +158,9 @@ def fixed_ssh_host? end def latest_images - @latest_images ||= ::Docker::Image.all({}, connection).find_all { |i| image_matches?(i, /^travis:/) } + @latest_images ||= ::Docker::Image.all({}, connection).find_all do |i| + image_matches?(i, /^#{Regexp.escape(docker_config.image_name)}:/) + end end def image_for_language(lang) @@ -174,7 +177,7 @@ def image_for_language(lang) end def default_image - latest_images.detect { |i| image_matches?(i, 'travis:ruby') } + latest_images.detect { |i| image_matches?(i, docker_config.default_image) } end def image_matches?(image, tag)