Sha256: c0e3726c8eecdb379c5948a11eeabc5367bbb1745b08cb1debcd102911c7343b

Contents?: true

Size: 868 Bytes

Versions: 12

Compression:

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
takelage-0.27.1 lib/takelage/docker/container/prune.rb
takelage-0.27.0 lib/takelage/docker/container/prune.rb
takelage-0.26.7 lib/takelage/docker/container/prune.rb
takelage-0.26.4 lib/takelage/docker/container/prune.rb
takelage-0.26.3 lib/takelage/docker/container/prune.rb
takelage-0.26.2 lib/takelage/docker/container/prune.rb
takelage-0.25.10 lib/takelage/docker/container/prune.rb
takelage-0.25.8 lib/takelage/docker/container/prune.rb
takelage-0.24.0 lib/takelage/docker/container/prune.rb
takelage-0.23.3 lib/takelage/docker/container/prune.rb
takelage-0.23.2 lib/takelage/docker/container/prune.rb
takelage-0.23.1 lib/takelage/docker/container/prune.rb