mservices

package
v3.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateContainer

CreateContainer finds and removes any existing container with the given name, then creates a fresh one from the provided options.

Existing Docker volumes are always preserved so that data survives a container re-creation. Returns the ID of the newly created container.

func ExecuteCommand

func ExecuteCommand(ctx context.Context, c *client.Client, id string, cmd []string) (client.ExecInspectResult, error)

Simply execute a command inside of a container.

func GetImageMajorVersion

func GetImageMajorVersion(image string) int

GetImageMajorVersion extracts the major version number from a Docker image tag. It searches for the first sequence of digits in the tag portion of the image name (after the colon) and returns it as an integer. For example:

  • "postgres:17" -> 17
  • "node:v20.1.0" -> 20
  • "nginx:1.25-alpine" -> 1

Returns -1 if no version number can be found.

Types

type ContainerVolume

type ContainerVolume struct {
	// Suffix appended to the container name to form the Docker volume name,
	// e.g. "data" -> "<containerName>-data".
	NameSuffix string
	// Absolute path inside the container where the volume is mounted.
	Target string
}

ContainerVolume describes a single named volume that should be mounted into the container. The volume name is derived from the container name so it survives container re-creation.

type ManagedContainerOptions

type ManagedContainerOptions struct {
	// Docker image to use, e.g. "postgres:17".
	Image string
	// Environment variables passed into the container.
	Env []string
	// Ports to expose. Each entry maps one container port (inside of the container) to one host port (chosen by Magic).
	Ports []string
	// Named volumes to attach. Existing mounts are reused across re-creations.
	Volumes []ContainerVolume
}

ManagedContainerOptions holds everything needed to create (or re-create) a managed Docker container in a reproducible way.

Jump to

Keyboard shortcuts

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