Start, wait for, and clean up Docker containers from Go.
dockermanage is a thin, opinionated layer over the official Docker client. It does not depend on the testing package, so you can use it in tools, local development setups, and services, as well as in tests.
- Sensible defaults, so the common case takes a few lines.
- Clear errors when a container fails to start.
- Cleanup that touches only the containers it started.
- Built-in support for PostgreSQL.
go get github.com/pressly/dockermanageRequires Go 1.26 or newer.
m, err := dockermanage.New()
if err != nil {
return err
}
defer m.Close()
c, err := m.Start(ctx, "redis:8-alpine", dockermanage.WithPort(6379))
if err != nil {
return err
}
defer c.Remove(context.WithoutCancel(ctx))
addr, err := c.Addr(6379) // for example, "127.0.0.1:54321"MIT. See LICENSE.