Class: LogStash::Filters::DockerContainerSupport::DockerContainerInspector

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/filters/docker_container/docker_container_inspector.rb

Instance Method Summary collapse

Constructor Details

#initialize(docker_client, client_options) ⇒ DockerContainerInspector

Returns a new instance of DockerContainerInspector.

Parameters:

  • docker_client (String)

    the Docker client executable to run. Either needs to be in $PATH or an absolute path

  • client_options (String)

    the command-line options to fine tune connectivity to the Docker daemon



9
10
11
12
# File 'lib/logstash/filters/docker_container/docker_container_inspector.rb', line 9

def initialize(docker_client, client_options)
  @docker_client = docker_client
  @client_options = client_options
end

Instance Method Details

#inspect(container_id) ⇒ String

Returns the ‘docker inspect` content or ’[]‘ if unable to find the container.

Parameters:

  • container_id (String)

Returns:

  • (String)

    the ‘docker inspect` content or ’[]‘ if unable to find the container



17
18
19
20
# File 'lib/logstash/filters/docker_container/docker_container_inspector.rb', line 17

def inspect(container_id)
  content = `#{@docker_client} #{@client_options} inspect #{container_id}`
  return $?.success? ? content : '[]'
end