Sha256: d441606a8fc9e63027ce507f79b2431c75d7859fca1f81858ba05122036f2fe2

Contents?: true

Size: 937 Bytes

Versions: 6

Compression:

Stored size: 937 Bytes

Contents

# frozen_string_literal: true

# takeltau 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

6 entries across 6 versions & 1 rubygems

Version Path
takeltau-0.34.15 lib/takeltau/docker/container/prune.rb
takeltau-0.34.14 lib/takeltau/docker/container/prune.rb
takeltau-0.34.13 lib/takeltau/docker/container/prune.rb
takeltau-0.34.12 lib/takeltau/docker/container/prune.rb
takeltau-0.34.11 lib/takeltau/docker/container/prune.rb
takeltau-0.34.9 lib/takeltau/docker/container/prune.rb