Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add docs regarding Podman usage #503

Merged
merged 1 commit into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions docs/features/using_podman.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Using Podman instead of Docker

Testcontainers supports to use Podman (rootless or rootful) instead of Docker.
In most scenarios no special setup is required.
Testcontainers will automatically discover the socket based on the `DOCKER_HOST` or the `TC_HOST` environment variables.
Alternatively you can also configure the host with a `.testcontainers.properties` file.
The discovered Docker host is also taken into account when starting a reaper container.

There's currently only one special case where additional configuration is necessary: complex container network scenarios.

By default Testcontainers takes advantage of the default network settings both Docker and Podman are applying to newly created containers.
It only intervenes in scenarios where a `ContainerRequest` specifies networks and does not include the default network of the current container provider.
Unfortunately the default network for Docker is called _bridge_ where the default network in Podman is called _podman_.
It is not even possible to create a network called _bridge_ with Podman as Podman does not allow creating a network with the same name as an already existing network mode.

In such scenarios it is possible to explicitly make use of the `ProviderPodman` like so:

```go

package some_test

import (
"testing"
tc "github.com/testcontainers/testcontainers-go"
)

func TestSomething(t *testing.T) {
req := tc.GenericContainerRequest{
ProviderType: tc.ProviderPodman,
ContainerRequest: tc.ContainerRequest{
Image: "docker.io/nginx:alpine"
},
}

// ...
}
```

The `ProviderPodman` configures the `DockerProvider` with the correct default network for Podman to ensure also complex network scenarios are working as with Docker.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ nav:
- features/follow_logs.md
- features/override_container_command.md
- features/copy_file.md
- features/using_podman.md
- Examples:
- examples/cockroachdb.md
- examples/nginx.md
Expand Down