v0.13.1 Latest Latest

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

Go to latest
Published: Aug 8, 2023 License: Apache-2.0 Imports: 16 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Config

type Config struct {

	// Image is the name of the image to pull and run.
	Image string
	// Env vars to pass to the docker container.
	Env []string
	// Internal Port to expose anc connect to.
	Port string
	// Database name to create and connect on init.
	Database string
	// Out is a custom writer to send docker cli output to.
	Out io.Writer
	// contains filtered or unexported fields

Config is used to configure container creation.

func FromURL added in v0.8.2

func FromURL(u *url.URL) (*Config, error)

FromURL parses a URL in the format of "docker://image/tag" and returns a Config.

func MariaDB

func MariaDB(version string, opts ...ConfigOption) (*Config, error)

MariaDB returns a new Config for a MariaDB image.

func MySQL

func MySQL(version string, opts ...ConfigOption) (*Config, error)

MySQL returns a new Config for a MySQL image.

func NewConfig

func NewConfig(opts ...ConfigOption) (*Config, error)

NewConfig returns a new config with the given options applied.

func PostgreSQL

func PostgreSQL(version string, opts ...ConfigOption) (*Config, error)

PostgreSQL returns a new Config for a PostgreSQL image.

func (*Config) Run

func (c *Config) Run(ctx context.Context) (*Container, error)

Run pulls and starts a new docker container from the Config.

type ConfigOption

type ConfigOption func(*Config) error

ConfigOption allows configuring Config with functional arguments.

func Database added in v0.8.2

func Database(name string) ConfigOption

Database sets the database name to connect to. For example:

func Env

func Env(env ...string) ConfigOption

Env sets the environment variables to pass to the container. For example:

Config(Image("mysql"), Env("MYSQL_ROOT_PASSWORD=password"))
Config(Image("postgres"), Env("MYSQL_ROOT_PASSWORD=password"))

func Image

func Image(parts ...string) ConfigOption

Image sets the docker image to use. For example:

Image("arigaio", "mysql")

func Out

func Out(w io.Writer) ConfigOption

Out sets an io.Writer to use when running docker commands. For example:

buf := new(bytes.Buffer)

func Port

func Port(p string) ConfigOption

Port sets the port the container services exposes. For example:


type Container

type Container struct {

	// ID of the container.
	ID string
	// Passphrase of the root user.
	Passphrase string
	// Port on the host this containers service is bound to.
	Port string
	// contains filtered or unexported fields

A Container is an instance of a created container.

func (*Container) Close

func (c *Container) Close() error

Close stops and removes this container.

func (*Container) URL

func (c *Container) URL() (*url.URL, error)

URL returns a URL to connect to the Container.

func (*Container) Wait

func (c *Container) Wait(ctx context.Context, timeout time.Duration) error

Wait waits for this container to be ready.

Jump to

Keyboard shortcuts

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