Testcontainers for Go is a Go package that makes it simple to create and clean up container-based dependencies for automated integration/smoke tests. The clean, easy-to-use API enables developers to programmatically define containers that should be run as part of a test and clean up those resources when the test is done.
docker pull testcontainers/testcontainers-go:latest
docker run -d --name testcontainers-go --restart always testcontainers/testcontainers-go:latest
docker compose up -d
services:
{{ .ServiceType }}-echo:
build:
dockerfile: echoserver.Dockerfile
environment:
FOO: "Hello, World!"
ports:
- target: 8080
published: {{ .Port_0 }}
protocol: tcp