Registry /
testing / testcontainers-testcontainers-go
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
testcontainers
✓ github.com/testcontainers/testcontainers-go
Starts an nginx container and waits for it to be ready.
package main
import (
"context"
"fmt"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/wait"
)
func main() {
ctx := context.Background()
req := testcontainers.ContainerRequest{
Image: "nginx:latest",
ExposedPorts: []string{"80/tcp"},
WaitingFor: wait.ForHTTP("/"),
}
container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: req,
Started: true,
})
if err != nil {
panic(err)
}
defer container.Terminate(ctx)
fmt.Println("Container started")
}
Debug
Known issues
No known issues recorded.
Upgrade
Version history
0.42.0latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.