-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker context and DOCKER_HOST env support #200
Conversation
f3b2c3d
to
9e51c97
Compare
Until this is merged, here's my painless hack. Drop the following code into a rake file (ie. # Patch docker targets in inventory to support DOCKER_HOST environment variable
task :patch_docker_inventory do
require 'yaml'
require 'uri'
hostname = if ENV.key? 'DOCKER_HOST'
URI.parse(ENV['DOCKER_HOST']).host || ENV['DOCKER_HOST']
else
'localhost'
end
if hostname != 'localhost'
inventory_fn = "#{__dir__}/../spec/fixtures/litmus_inventory.yaml"
data = YAML.load_file(inventory_fn)
data['groups'].map do |group|
if group['targets'].size > 0
group['targets'].map do |target|
target['uri'].gsub!('localhost', hostname) if target['facts']['provisioner'] == 'docker' && target['uri'] =~ %r{^localhost:}
end
end
end
File.open(inventory_fn, 'w') { |f| f.write(data.to_yaml) }
end
end
Rake::Task['litmus:provision'].enhance do
Rake::Task['patch_docker_inventory'].execute
end
Rake::Task['litmus:provision_list'].enhance do
Rake::Task['patch_docker_inventory'].execute
end |
hey @h0tw1r3 thanks for this, its great! Could you please:
Thanks again. 🚀 |
@jordanbreen28 Can you point me to the existing docker spec tests? |
Standard use cases are a docker CI runner using a remote docker to avoid the pitfalls of docker-in-docker, or a workstation which must to use a remote docker service (ie. Windows in AWS workspaces, security requirement, etc). The "DOCKER_HOST" way, is universally supported by all docker versions. export DOCKER_HOST=docker0.dev.internal:2376
pdk bundle exec rake 'litmus:provision[docker, litmusimage/ubuntu:22.04]'
pdk bundle exec rake litmus:install_agent
pdk bundle exec rake litmus:acceptance:parallel The modern way, is to use contexts.
|
Adds support for parsing the docker context or DOCKER_HOST environment variable to determine the hostname used to connect to the instance.