docker

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

Close closes the Docker client

func ContainerExists

func ContainerExists(containerID string) bool

ContainerExists checks if a container exists

func CreateContainer

func CreateContainer(dbType, displayName, username, password, port, volumeType, volumePath, version string) (string, error)

CreateContainer creates and starts a database container

func CreateUser

func CreateUser(containerID, dbType, adminUser, adminPassword, username, password, dbName string) error

CreateUser creates a new user in the database. admin* are the privileged credentials used to authenticate the operation.

func DeleteUser

func DeleteUser(containerID, dbType, adminUser, adminPassword, username, dbName string) error

DeleteUser deletes a user from the database.

func ExecCommand

func ExecCommand(containerID string, cmd []string) (string, error)

ExecCommand runs a command in a container and returns its combined, demultiplexed stdout/stderr output.

func ExecCommandStdin added in v0.5.0

func ExecCommandStdin(containerID string, cmd []string, stdin []byte) (string, error)

ExecCommandStdin runs a command in a container, writing stdin to it, and returns the combined, demultiplexed stdout/stderr output. It is used to feed schema/seed scripts to a database client (e.g. psql, mysql).

func FindAvailablePort

func FindAvailablePort(startPort string) (string, error)

FindAvailablePort finds the next available port starting from startPort.

func GetActualVersion

func GetActualVersion(containerID, dbType string) (string, error)

GetActualVersion retrieves the actual database version from a running container

func GetConfigFileName

func GetConfigFileName(dbType string) string

GetConfigFileName returns the main config file name for the database type

func Initialize

func Initialize() error

Initialize creates a Docker client. It does not contact the daemon, so commands that only read local state (version, ls, info) work while Docker is down; commands that need the daemon surface a clear error on first use.

func IsPortAvailable

func IsPortAvailable(port string) (bool, error)

IsPortAvailable reports whether a TCP port can be bound on the host. This catches both Docker-published ports and any other local process.

func Ping added in v0.5.0

func Ping(ctx context.Context) error

Ping verifies that the Docker daemon is reachable.

func RemoveContainer

func RemoveContainer(containerID string) error

RemoveContainer removes a container

func RemoveVolume

func RemoveVolume(volumeType, volumePath string) error

RemoveVolume removes the on-disk data for a container's volume. mkdb "named" volumes are bind-mounted directories under the data dir; bind mounts point at a user-supplied path and are left untouched.

func RestartContainer

func RestartContainer(containerID string) error

RestartContainer restarts a container

func RotatePassword

func RotatePassword(containerID, dbType, adminUser, adminPassword, username, newPassword, dbName string) error

RotatePassword rotates a user's password.

func StartContainer

func StartContainer(containerID string) error

StartContainer starts an existing (stopped) container

func StopContainer

func StopContainer(containerID string) error

StopContainer stops a container gracefully

Types

type DBConfig

type DBConfig struct {
	Image       string
	DefaultPort string
	EnvVars     map[string]string
}

DBConfig represents database-specific configuration

func GetDBConfig

func GetDBConfig(dbType, version string) (*DBConfig, error)

GetDBConfig returns the configuration for a database type, or an error if the type is unknown.

type ManagedContainer added in v0.5.0

type ManagedContainer struct {
	ID    string
	Name  string // mkdb display name (from the mkdb.name label)
	State string // Docker state, e.g. "running", "exited"
}

ManagedContainer is a summary of a Docker container created by mkdb.

func ListManaged added in v0.5.0

func ListManaged(ctx context.Context) ([]ManagedContainer, error)

ListManaged returns all Docker containers labeled as mkdb-managed, running or not. It is used by `mkdb doctor` to detect drift between Docker and mkdb's own state.

Jump to

Keyboard shortcuts

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