sorter

package
v1.12.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package sorter topologically orders containers by their declared depends-on and links graph so updates happen in a safe order.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortByDependencies

func SortByDependencies(containers []types.Container, includeComposeDepends bool) ([]types.Container, error)

SortByDependencies will sort the list of containers taking into account any links between containers. Container with no outgoing links will be sorted to the front of the list while containers with links will be sorted after all of their dependencies. This sort order ensures that linked containers can be started in the correct order.

When includeComposeDepends is true, Watchtower also augments the graph with edges derived from Docker Compose's com.docker.compose.depends_on labels — service names resolved to container names within the same Compose project. Opt-in because it changes the order (and therefore stop/start behaviour) for Compose-managed stacks that currently rely on watchtower only seeing the explicit com.centurylinklabs.watchtower.depends-on label.

Types

type ByCreated

type ByCreated []types.Container

ByCreated allows a list of Container structs to be sorted by the container's created date.

func (ByCreated) Len

func (c ByCreated) Len() int

func (ByCreated) Less

func (c ByCreated) Less(i, j int) bool

Less will compare two elements (identified by index) in the Container list by created-date.

func (ByCreated) Swap

func (c ByCreated) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL