Containers Ohai Plugin
Yeah so this is cool. It will collect all information about every LXC or Docker container whether it is running or not. Hopefully, we can add platform_family and other pieces to it as well. Then, this would allow us to write some awesome multi-provider cookbooks to extend package, service, execute, etc.
Install & Usage Instructions
Containers
Here's how to use it: https://chefheads.wordpress.com/2015/04/06/ohai-using-custom-ohai-plugins/<br />
<p>This will collect and store all information about current containers either running or not. To check it out, try it and take a look at node[:containers]. This will traverse as many levels needed to gather the docker information that is stored as JSON.</p>
<p>Here's an example output from node[:containers]:</p>
{"lxc"=>{"container"=>{"base_box"=>{"name"=>"base_box", "state"=>"RUNNING", "pid"=>"6891", "ip"=>"10.0.3.20", "cpu_use"=>"1.03 seconds", "blkio_use"=>"264.00 KiB", "memory_use"=>"6.27 MiB", "kmem_use"=>"0 bytes", "link"=>"vethC1FD99", "tx_bytes"=>"213.56 KiB", "rx_bytes"=>"5.57 MiB", "total_bytes"=>"5.78 MiB"}, "base_clone"=>{"name"=>"base_clone", "state"=>"STOPPED"}, "base_clone_eph"=>{"name"=>"base_clone_eph", "state"=>"RUNNING", "pid"=>"6390", "ip"=>"10.0.3.218", "cpu_use"=>"1.08 seconds", "blkio_use"=>"3.51 MiB", "memory_use"=>"9.15 MiB", "kmem_use"=>"0 bytes", "link"=>"vethMF8QOC", "tx_bytes"=>"4.04 KiB", "rx_bytes"=>"6.00 KiB", "total_bytes"=>"10.04 KiB"}}, "host"=>true},
<br/><br/>
"docker"=>{"container"=>{"ce68ab709910"=>{"State"=>{"Running"=>false, "Paused"=>false, "Restarting"=>false, "OOMKilled"=>false, "Pid"=>0, "ExitCode"=>127, "Error"=>"", "StartedAt"=>"2015-04-06T05:18:56.062237133Z", "FinishedAt"=>"2015-04-06T05:19:19.75970348Z"}, "ID"=>"ce68ab70991053984d1f901fc1e7f409a5f8a9c2b3f682c1684c5a375ee9ef2a", "Created"=>"2015-04-06T05:18:55.295190458Z", "Path"=>"/bin/bash", "Args"=>[], "Config"=>{"Hostname"=>"ce68ab709910", "Domainname"=>"", "User"=>"", "Memory"=>0, "MemorySwap"=>0, "CpuShares"=>0, "Cpuset"=>"", "AttachStdin"=>true, "AttachStdout"=>true, "AttachStderr"=>true, "PortSpecs"=>nil, "ExposedPorts"=>nil, "Tty"=>true, "OpenStdin"=>true, "StdinOnce"=>true, "Env"=>["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"], "Cmd"=>["/bin/bash"], "Image"=>"ubuntu:14.04", "Volumes"=>nil, "WorkingDir"=>"", "Entrypoint"=>nil, "NetworkDisabled"=>false, "MacAddress"=>"", "OnBuild"=>nil}, "Image"=>"d0955f21bf24f5bfffd32d2d0bb669d0564701c271bc3dfc64cfc5adfdec2d07", "NetworkSettings"=>{"IPAddress"=>"", "IPPrefixLen"=>0, "MacAddress"=>"", "LinkLocalIPv6Address"=>"", "LinkLocalIPv6PrefixLen"=>0, "GlobalIPv6Address"=>"", "GlobalIPv6PrefixLen"=>0, "Gateway"=>"", "IPv6Gateway"=>"", "Bridge"=>"", "PortMapping"=>nil, "Ports"=>nil}, "ResolvConfPath"=>"/var/lib/docker/containers/ce68ab70991053984d1f901fc1e7f409a5f8a9c2b3f682c1684c5a375ee9ef2a/resolv.conf", "HostnamePath"=>"/var/lib/docker/containers/ce68ab70991053984d1f901fc1e7f409a5f8a9c2b3f682c1684c5a375ee9ef2a/hostname", "HostsPath"=>"/var/lib/docker/containers/ce68ab70991053984d1f901fc1e7f409a5f8a9c2b3f682c1684c5a375ee9ef2a/hosts", "Name"=>"/furious_shockley", "Driver"=>"aufs", "ExecDriver"=>"native-0.2", "MountLabel"=>"", "ProcessLabel"=>"", "AppArmorProfile"=>"", "RestartCount"=>0, "UpdateDns"=>false, "Volumes"=>{}, "VolumesRW"=>{}, "AppliedVolumesFrom"=>nil}}, "host"=>true}}