Sha256: 0f3fcb7fc434deee348bcf0f6d66eca7fce1b59b7808b40db611959b4453fbe1

Contents?: true

Size: 937 Bytes

Versions: 23

Compression:

Stored size: 937 Bytes

Contents

# frozen_string_literal: true

# takelage docker container prune
module DockerContainerPrune
  # Backend method for docker container prune.
  def docker_container_prune
    log.debug 'Removing orphaned docker containers'

    return false unless docker_check_daemon

    networks = _docker_container_prune_kill_orphaned_containers
    _docker_container_lib_remove_networks networks
  end

  private

  # Kill orphaned docker containers and return list of networks.
  def _docker_container_prune_kill_orphaned_containers
    networks = []

    _docker_container_lib_get_containers.each do |container|
      next unless docker_container_check_orphaned container

      name = _docker_container_lib_get_container_name_by_id container
      mutagen_socket_terminate "--label-selector='hostname=#{name}'"
      _docker_container_lib_stop_container container
      networks << name unless networks.include? name
    end
    networks
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
takelage-0.33.1 lib/takelage/docker/container/prune.rb
takelage-0.32.4 lib/takelage/docker/container/prune.rb
takelage-0.32.3 lib/takelage/docker/container/prune.rb
takelage-0.32.1 lib/takelage/docker/container/prune.rb
takelage-0.32.0 lib/takelage/docker/container/prune.rb
takelage-0.31.0 lib/takelage/docker/container/prune.rb
takelage-0.30.6 lib/takelage/docker/container/prune.rb
takelage-0.30.5 lib/takelage/docker/container/prune.rb
takelage-0.30.1 lib/takelage/docker/container/prune.rb
takelage-0.30.0 lib/takelage/docker/container/prune.rb
takelage-0.29.14 lib/takelage/docker/container/prune.rb
takelage-0.29.13 lib/takelage/docker/container/prune.rb
takelage-0.29.11 lib/takelage/docker/container/prune.rb
takelage-0.29.10 lib/takelage/docker/container/prune.rb
takelage-0.29.8 lib/takelage/docker/container/prune.rb
takelage-0.29.6 lib/takelage/docker/container/prune.rb
takelage-0.29.0 lib/takelage/docker/container/prune.rb
takelage-0.28.26 lib/takelage/docker/container/prune.rb
takelage-0.28.24 lib/takelage/docker/container/prune.rb
takelage-0.28.14 lib/takelage/docker/container/prune.rb