---
title: "Using modules for Testcontainers with Golang"
description: "Testcontainers for Go lets integration tests start real dependencies such as Redis in containers, but raw usage requires knowing ports, wait strategies and environment details."
url: "https://swe.quest/articles/using-modules-for-testcontainers-with-golang-07887e1f0f647794"
canonical: "https://engineering.zalando.com/posts/2023/12/using-modules-for-testcontainers-with-golang.html"
source: "Zalando Engineering"
published: "2023-12-18"
difficulty: "medium"
kind: "How-to"
reading_minutes: 4
tags: ["testing","go","containers"]
---

# Using modules for Testcontainers with Golang

A post on [Zalando Engineering](https://swe.quest/sources/zalando.md), published 2023-12-18, 4 min read, How-to. Original: [https://engineering.zalando.com/posts/2023/12/using-modules-for-testcontainers-with-golang.html](https://engineering.zalando.com/posts/2023/12/using-modules-for-testcontainers-with-golang.html)

## Summary

Testcontainers for Go lets integration tests start real dependencies such as Redis in containers, but raw usage requires knowing ports, wait strategies and environment details. Zalando built an internal wrapper library using the Functional Options Pattern to supply per-dependency defaults, then migrated to the official Testcontainers modules, which do the same job and cut maintenance. A common problem is the Ryuk garbage-collector sidecar failing under Podman; it can be fixed by disabling it with TESTCONTAINERS\_RYUK\_DISABLED or by running Podman rootful with the privileged and Docker socket override variables.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)
- [Go](https://swe.quest/tags/go.md) (Languages)
- [Containers](https://swe.quest/tags/containers.md) (Infrastructure)

## Prerequisites

- Go testing basics ([easy posts on Go](https://swe.quest/tags/go.md?difficulty=easy))
- Docker containers ([easy posts on Containers](https://swe.quest/tags/containers.md?difficulty=easy))
- integration testing ([easy posts on Testing](https://swe.quest/tags/testing.md?difficulty=easy))

## Keywords

Testcontainers, Ryuk, Podman, Redis, Docker, Functional Options Pattern

## Related posts

- [GoFiber v3 + Testcontainers: Production-like Local Dev with Air](https://swe.quest/articles/gofiber-v3-testcontainers-production-like-local-dev-with-air-d8c159a9b0421bda.md): Docker · 2025-07-17 · Medium · 15 min read · Go, Testing, Developer productivity, Containers, PostgreSQL
  Fiber v3's new Services API lets a Go web app start and stop backing dependencies as part of its own lifecycle, and a Testcontainers contrib module plugs real Docker containers into it.
- [Functional tests with Testcontainers](https://swe.quest/articles/functional-tests-with-testcontainers-8e8bddfb01d0b1bc.md): Zalando Engineering · 2022-04-11 · Medium · 7 min read · Testing, Java & JVM, Containers
  Black-box functional tests for a Spring service can run against the service packaged as a Docker image, with PostgreSQL and other dependencies started as separate containers via Testcontainers.
- [Shift-Left Testing with Testcontainers: Catching Bugs Early with Local Integration Tests](https://swe.quest/articles/shift-left-testing-with-testcontainers-catching-bugs-early-with-local-f90241b596ffcd90.md): Docker · 2025-03-13 · Medium · 10 min read · Testing, Developer productivity, PostgreSQL, TypeScript
  Running integration tests locally against real dependencies via Testcontainers catches bugs that unit tests and mocks miss, before code reaches shared CI or staging environments.
- [Why Testcontainers Cloud Is a Game-Changer Compared to Docker-in-Docker for Testing Scenarios](https://swe.quest/articles/why-testcontainers-cloud-is-a-game-changer-compared-to-docker-in-docker-for-206c0ecf09c497e2.md): Docker · 2024-11-14 · Medium · 8 min read · Testing, CI/CD, Containers
  Docker-in-Docker, commonly used to give CI jobs a Docker daemon for Testcontainers integration tests, requires privileged mode and nests storage drivers, cgroups and namespaces, which leads to security audit problems, flaky builds, slow pipelines and hard debugging.
- [Streamlining Local Development with Dev Containers and Testcontainers Cloud](https://swe.quest/articles/streamlining-local-development-with-dev-containers-and-testcontainers-cloud-050962d8604171c1.md): Docker · 2024-08-27 · Medium · 7 min read · Containers, Testing, Developer tools, Java & JVM
  Testcontainers-based tests and services can run inside a dev container by giving the container Docker access, either through the Docker-in-Docker feature or by swapping in the Testcontainers Cloud feature, which runs an agent that points Docker calls at a remote cloud environment.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
