docker

package
v0.2.22 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCleanCommandArgs

func BuildCleanCommandArgs(services []string, profiles ...string) (rmArgs, buildArgs, upArgs []string)

BuildCleanCommandArgs builds docker compose arguments for clean operation.

  • upArgs: arguments to start the services detached (`compose up -d ...`)

func BuildRestartCommandArgs

func BuildRestartCommandArgs(services []string, profiles ...string) (stopArgs, upArgs []string)

BuildRestartCommandArgs builds docker compose arguments for restart operation. BuildRestartCommandArgs builds Docker Compose argument lists to stop then start the specified services, injecting each provided profile as a `--profile <name>` flag immediately after `compose`. The first returned slice is the arguments for `docker compose stop <services>`; the second is for `docker compose up -d <services>`.

func GetContainers

func GetContainers() ([]string, error)

GetContainers returns the names of running Docker containers. It runs `docker ps --format "{{.Names}}"`, splits the output by newline, filters out empty names, and returns the resulting slice. An error is returned if the `docker` command fails.

func GetServices

func GetServices(projectDir string, profiles ...string) ([]string, error)

GetServices retrieves a list of services from docker-compose config. GetServices runs `docker compose config --services` in the specified project directory and returns the configured service names. If profiles are provided they are passed as `--profile <name>` flags to the compose command. The command output is split on whitespace to produce the returned service name slice. If the docker command fails, an error is returned.

func RunCommand

func RunCommand(projectDir string, args ...string) error

RunCommand executes a Docker command with the given arguments in the specified project directory. RunCommand runs the specified docker subcommand with args inside projectDir and streams stdout and stderr to the current terminal. It returns an error wrapping the underlying execution failure if the docker process exits with a non-zero status.

Types

This section is empty.

Jump to

Keyboard shortcuts

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