Sha256: cdb6ff3ee8c0d16e3905f254134b92d4a7723473bdb007348d2c173d33a9f7e3

Contents?: true

Size: 869 Bytes

Versions: 9

Compression:

Stored size: 869 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_running

    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
      _docker_container_lib_stop_container container
      networks << name unless networks.include? name
    end
    networks
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
takelage-0.23.0 lib/takelage/docker/container/prune.rb
takelage-0.22.2 lib/takelage/docker/container/prune.rb
takelage-0.22.1 lib/takelage/docker/container/prune.rb
takelage-0.22.0 lib/takelage/docker/container/prune.rb
takelage-0.21.1 lib/takelage/docker/container/prune.rb
takelage-0.21.0 lib/takelage/docker/container/prune.rb
takelage-0.20.2 lib/takelage/docker/container/prune.rb
takelage-0.20.1 lib/takelage/docker/container/prune.rb
takelage-0.20.0 lib/takelage/docker/container/prune.rb