lib/kitchen/driver/docker.rb in kitchen-docker-1.3.1 vs lib/kitchen/driver/docker.rb in kitchen-docker-1.4.0
- old
+ new
@@ -1,8 +1,8 @@
# -*- encoding: utf-8 -*-
#
-# Copyright (C) 2013, Sean Porter
+# Copyright (C) 2014, Sean Porter
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@@ -31,11 +31,11 @@
default_config :binary, 'docker'
default_config :socket, 'unix:///var/run/docker.sock'
default_config :privileged, false
default_config :use_cache, true
default_config :remove_images, false
- default_config :run_command, '/usr/sbin/sshd -D -o UseDNS=no -o UsePAM=no'
+ default_config :run_command, '/usr/sbin/sshd -D -o UseDNS=no -o UsePAM=no -o UsePrivilegeSeparation=no -o PidFile=/tmp/sshd.pid'
default_config :username, 'kitchen'
default_config :password, 'kitchen'
default_config :tls, false
default_config :tls_verify, false
default_config :tls_cacert, nil
@@ -141,11 +141,10 @@
"Unknown platform '#{config[:platform]}'"
end
username = config[:username]
password = config[:password]
base = <<-eos
- RUN mkdir -p /var/run/sshd
RUN useradd -d /home/#{username} -m -s /bin/bash #{username}
RUN echo #{username}:#{password} | chpasswd
RUN echo '#{username} ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
eos
custom = ''
@@ -194,14 +193,17 @@
def build_run_command(image_id)
cmd = "run -d -p 22"
Array(config[:forward]).each {|port| cmd << " -p #{port}"}
Array(config[:dns]).each {|dns| cmd << " -dns #{dns}"}
Array(config[:volume]).each {|volume| cmd << " -v #{volume}"}
+ Array(config[:volumes_from]).each {|container| cmd << " --volumes-from #{container}"}
cmd << " -h #{config[:hostname]}" if config[:hostname]
cmd << " -m #{config[:memory]}" if config[:memory]
cmd << " -c #{config[:cpu]}" if config[:cpu]
cmd << " -privileged" if config[:privileged]
+ cmd << " -e http_proxy=#{config[:http_proxy]}" if config[:http_proxy]
+ cmd << " -e https_proxy=#{config[:https_proxy]}" if config[:https_proxy]
cmd << " #{image_id} #{config[:run_command]}"
cmd
end
def run_container(state)
@@ -220,10 +222,10 @@
end
def parse_container_ssh_port(output)
begin
info = Array(::JSON.parse(output)).first
- ports = info['NetworkSettings']['Ports']
+ ports = info['NetworkSettings']['Ports'] || info['HostConfig']['PortBindings']
ssh_port = ports['22/tcp'].detect {|port| port['HostIp'] == '0.0.0.0'}
ssh_port['HostPort'].to_i
rescue
raise ActionFailed,
'Could not parse Docker inspect output for container SSH port'