lib/kitchen/driver/docker.rb in kitchen-docker-1.5.0 vs lib/kitchen/driver/docker.rb in kitchen-docker-1.6.0
- old
+ new
@@ -27,22 +27,24 @@
#
# @author Sean Porter <portertech@gmail.com>
class Docker < Kitchen::Driver::SSHBase
default_config :binary, 'docker'
- default_config :socket, 'unix:///var/run/docker.sock'
+ default_config :socket, ENV['DOCKER_HOST'] || '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 -o UsePrivilegeSeparation=no -o PidFile=/tmp/sshd.pid'
+ default_config :run_command, '/usr/sbin/sshd -D -o UseDNS=no -o UsePAM=no -o PasswordAuthentication=yes ' +
+ '-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
default_config :tls_cert, nil
default_config :tls_key, nil
+ default_config :publish_all, false
default_config :use_sudo do |driver|
!driver.remote_socket?
end
@@ -55,11 +57,11 @@
end
default_config :disable_upstart, true
def verify_dependencies
- run_command("#{config[:binary]} > /dev/null", :quiet => true)
+ run_command("#{config[:binary]} >> /dev/null 2>&1", :quiet => true)
rescue
raise UserError,
'You must first install the Docker CLI tool http://www.docker.io/gettingstarted/'
end
@@ -123,11 +125,11 @@
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y sudo openssh-server curl lsb-release
eos
config[:disable_upstart] ? disable_upstart + packages : packages
- when 'rhel', 'centos'
+ when 'rhel', 'centos', 'fedora'
<<-eos
RUN yum clean all
RUN yum install -y sudo openssh-server openssh-clients which curl
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''
@@ -137,20 +139,35 @@
RUN pacman -Syu --noconfirm
RUN pacman -S --noconfirm openssh sudo curl
RUN ssh-keygen -A -t rsa -f /etc/ssh/ssh_host_rsa_key
RUN ssh-keygen -A -t dsa -f /etc/ssh/ssh_host_dsa_key
eos
+ when 'gentoo'
+ <<-eos
+ RUN emerge sync
+ RUN emerge net-misc/openssh app-admin/sudo
+ RUN ssh-keygen -A -t rsa -f /etc/ssh/ssh_host_rsa_key
+ RUN ssh-keygen -A -t dsa -f /etc/ssh/ssh_host_dsa_key
+ eos
+ when 'gentoo-paludis'
+ <<-eos
+ RUN cave sync
+ RUN cave resolve -zx net-misc/openssh app-admin/sudo
+ RUN ssh-keygen -A -t rsa -f /etc/ssh/ssh_host_rsa_key
+ RUN ssh-keygen -A -t dsa -f /etc/ssh/ssh_host_dsa_key
+ eos
else
raise ActionFailed,
"Unknown platform '#{config[:platform]}'"
end
username = config[:username]
password = config[:password]
base = <<-eos
RUN useradd -d /home/#{username} -m -s /bin/bash #{username}
RUN echo #{username}:#{password} | chpasswd
RUN echo '#{username} ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
+ RUN echo '#{username} ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/#{username}
eos
custom = ''
Array(config[:provision_command]).each do |cmd|
custom << "RUN #{cmd}\n"
end
@@ -197,9 +214,12 @@
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}"}
+ Array(config[:links]).each {|link| cmd << " --link #{link}"}
+ cmd << " --name #{config[:instance_name]}" if config[:instance_name]
+ cmd << " -P" if config[:publish_all]
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]