Skip to content
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
7 changes: 7 additions & 0 deletions docs/features/common_functional_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,13 @@ ctr, err := mymodule.Run(ctx, "docker.io/myservice:1.2.3",

If you need to prevent the container from being started after creation, you can use the `testcontainers.WithNoStart` option.

##### WithProvider

- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>

If you need specify which provider to use to run the container, you can use the `testcontainers.WithProvider` option.
Currently only `docker` or `podman` are supported.

#### Experimental Options

##### WithReuseByName
Expand Down
2 changes: 2 additions & 0 deletions docs/features/common_functional_options_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ The following options are exposed by the `testcontainers` package.
- [`CustomizeRequest`](/features/creating_container/#customizerequest) Since <a href="https://github.com/testcontainers/testcontainers-go/releases/tag/v0.20.0"><span class="tc-version">:material-tag: v0.20.0</span></a>
- [`WithName`](/features/creating_container/#withname) Since <a href="https://github.com/testcontainers/testcontainers-go/releases/tag/v0.38.0"><span class="tc-version">:material-tag: v0.38.0</span></a>
- [`WithNoStart`](/features/creating_container/#withnostart) Since <a href="https://github.com/testcontainers/testcontainers-go/releases/tag/v0.38.0"><span class="tc-version">:material-tag: v0.38.0</span></a>
- [`WithProvider`](/features/creating_container/#withprovider) Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>


### Experimental Options

Expand Down
38 changes: 38 additions & 0 deletions docs/system_requirements/using_podman.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,44 @@ The reaper container needs to connect to the docker daemon to reap containers, s
> systemctl --user start podman.socket
```

## MacOS

Currently, in MacOS the autodetection of podman does not work as intended, which leads to Ryuk failing at boot-up.
In order to use Testcontainers then either
1. Disable Ryuk (not recommended): see [here](../features/garbage_collector.md#ryuk)
2. If you want to use Ryuk then you need
1. Run podman in rootful mode by running the following commands
```bash
podman machine stop
podman machine set --rootful
podman machine start
```
2. Add
```
ryuk.container.privileged=true
```
to `~/.testcontainers.properties`
3. Use the `WithProvider` option when running your containers
```go
package some_test

import (
"testing"

tc "github.com/testcontainers/testcontainers-go"
)

func TestSomething(t *testing.T) {
ctx := t.Context()
ctr, err := tc.Run(ctx,
"docker.io/myservice:1.2.3",
tc.WithProvider(tc.ProviderPodman),
)

// ...
}
```

## Fedora

`DOCKER_HOST` environment variable must be set
Expand Down
9 changes: 9 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,3 +537,12 @@ func WithFiles(files ...ContainerFile) CustomizeRequestOption {
return nil
}
}

// WithProvider sets the provider type for a container
func WithProvider(provider ProviderType) CustomizeRequestOption {
return func(req *GenericContainerRequest) error {
req.ProviderType = provider

return nil
}
}
27 changes: 27 additions & 0 deletions options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -906,3 +906,30 @@ func TestWithWaitStrategy(t *testing.T) {
})
})
}

func TestWithProvider(t *testing.T) {
t.Parallel()
req := testcontainers.GenericContainerRequest{
ContainerRequest: testcontainers.ContainerRequest{
Image: "alpine",
},
}

t.Run("default", func(t *testing.T) {
opt := testcontainers.WithProvider(testcontainers.ProviderDefault)
require.NoError(t, opt.Customize(&req))
require.Equal(t, testcontainers.ProviderDefault, req.ProviderType)
})

t.Run("docker", func(t *testing.T) {
opt := testcontainers.WithProvider(testcontainers.ProviderDocker)
require.NoError(t, opt.Customize(&req))
require.Equal(t, testcontainers.ProviderDocker, req.ProviderType)
})

t.Run("podman", func(t *testing.T) {
opt := testcontainers.WithProvider(testcontainers.ProviderPodman)
require.NoError(t, opt.Customize(&req))
require.Equal(t, testcontainers.ProviderPodman, req.ProviderType)
})
}
Loading