Skip to content

Commit

Permalink
Added support for the 'insecure-registry' docker daemon option.
Browse files Browse the repository at this point in the history
  • Loading branch information
jperville committed Nov 12, 2014
1 parent 0fd4fb5 commit 95f3d8c
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ group | Group for docker socket and group_members | String | nil (implicitly doc
host | Socket(s) that docker should bind | String, Array | unix:///var/run/docker.sock
http_proxy | HTTP_PROXY environment variable | String | nil
icc | Enable inter-container communication | TrueClass, FalseClass | nil (implicitly true)
insecure-registry | List of well-known insecure registries | String, Array | nil
ip | Default IP address to use when binding container ports | String | nil (implicitly 0.0.0.0)
iptables | Enable Docker's addition of iptables rules | TrueClass, FalseClass | nil (implicitly true)
logfile | Set custom DOCKER_LOGFILE | String | nil
Expand Down
1 change: 1 addition & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
end
default['docker']['http_proxy'] = nil
default['docker']['icc'] = nil
default['docker']['insecure-registry'] = nil
default['docker']['ip'] = nil
default['docker']['iptables'] = nil
default['docker']['mtu'] = nil
Expand Down
1 change: 1 addition & 0 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def self.daemon_cli_args(node)
'graph' => node['docker']['graph'],
'group' => node['docker']['group'],
'icc' => node['docker']['icc'],
'insecure-registry' => Array(node['docker']['insecure-registry']),
'ip' => node['docker']['ip'],
'iptables' => node['docker']['iptables'],
'mtu' => node['docker']['mtu'],
Expand Down
26 changes: 26 additions & 0 deletions spec/systemd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,32 @@
end
end

context 'when insecure-registry is set with String' do
let(:chef_run) do
runner = ChefSpec::Runner.new
runner.node.set['docker']['insecure-registry'] = 'registry.example.com:1337'
runner.converge(described_recipe)
end

it 'adds insecure-registry flag to docker service' do
expect(chef_run).to render_file('/usr/lib/systemd/system/docker.service').with_content(
%r{^ExecStart=/usr/bin/docker -d.* --insecure-registry=registry\.example\.com:1337.*})
end
end

context 'when insecure-registry is set with Array' do
let(:chef_run) do
runner = ChefSpec::Runner.new
runner.node.set['docker']['insecure-registry'] = %w(registry.example.com:1337 registry.example.com:1338)
runner.converge(described_recipe)
end

it 'adds insecure-registry flags to docker service' do
expect(chef_run).to render_file('/usr/lib/systemd/system/docker.service').with_content(
%r{^ExecStart=/usr/bin/docker -d.* --insecure-registry=registry\.example\.com:1337 --insecure-registry=registry\.example\.com:1338.*})
end
end

context 'when ip is set' do
let(:chef_run) do
runner = ChefSpec::Runner.new
Expand Down
26 changes: 26 additions & 0 deletions spec/sysv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,32 @@
end
end

context 'when insecure-registry is set with String' do
let(:chef_run) do
runner = ChefSpec::Runner.new
runner.node.set['docker']['insecure-registry'] = 'registry.example.com:1337'
runner.converge(described_recipe)
end

it 'adds insecure-registry flag to docker service' do
expect(chef_run).to render_file('/etc/default/docker').with_content(
/^DOCKER_OPTS='.* --insecure-registry=registry\.example\.com:1337.*'$/)
end
end

context 'when insecure-registry is set with Array' do
let(:chef_run) do
runner = ChefSpec::Runner.new
runner.node.set['docker']['insecure-registry'] = %w(registry.example.com:1337 registry.example.com:1338)
runner.converge(described_recipe)
end

it 'adds insecure-registry flags to docker service' do
expect(chef_run).to render_file('/etc/default/docker').with_content(
/^DOCKER_OPTS='.* --insecure-registry=registry\.example\.com:1337 --insecure-registry=registry\.example\.com:1338.*'$/)
end
end

context 'when ip is set' do
let(:chef_run) do
runner = ChefSpec::Runner.new
Expand Down
26 changes: 26 additions & 0 deletions spec/upstart_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,32 @@
end
end

context 'when insecure-registry is set with String' do
let(:chef_run) do
runner = ChefSpec::Runner.new
runner.node.set['docker']['insecure-registry'] = 'registry.example.com:1337'
runner.converge(described_recipe)
end

it 'adds insecure-registry flag to docker service' do
expect(chef_run).to render_file('/etc/default/docker').with_content(
/^DOCKER_OPTS='.* --insecure-registry=registry\.example\.com:1337.*'$/)
end
end

context 'when insecure-registry is set with Array' do
let(:chef_run) do
runner = ChefSpec::Runner.new
runner.node.set['docker']['insecure-registry'] = %w(registry.example.com:1337 registry.example.com:1338)
runner.converge(described_recipe)
end

it 'adds insecure-registry flags to docker service' do
expect(chef_run).to render_file('/etc/default/docker').with_content(
/^DOCKER_OPTS='.* --insecure-registry=registry\.example\.com:1337 --insecure-registry=registry\.example\.com:1338.*'$/)
end
end

context 'when ip is set' do
let(:chef_run) do
runner = ChefSpec::Runner.new
Expand Down

0 comments on commit 95f3d8c

Please sign in to comment.