diff options
Diffstat (limited to 'lib/chef/dsl/platform_introspection.rb')
-rw-r--r-- | lib/chef/dsl/platform_introspection.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/chef/dsl/platform_introspection.rb b/lib/chef/dsl/platform_introspection.rb index 276a03af63..679b702383 100644 --- a/lib/chef/dsl/platform_introspection.rb +++ b/lib/chef/dsl/platform_introspection.rb @@ -245,6 +245,19 @@ class Chef end end + # Shamelessly stolen from https://github.com/sethvargo/chef-sugar/blob/master/lib/chef/sugar/docker.rb + # Given a node object, returns whether the node is a docker container. + # + # === Parameters + # node:: [Chef::Node] The node to check. + # + # === Returns + # true:: if the current node is a docker container + # false:: if the current node is not a docker container + def docker?(node) + ::File.exist?('/.dockerinit') || ::File.exist?('/.dockerenv') + end + end end end |