Skip to content

Commit

Permalink
Add TESTCONTAINERS_RYUK_CONTAINER_USER_NAMESPACE
Browse files Browse the repository at this point in the history
  • Loading branch information
scorpionknifes committed Aug 6, 2024
1 parent b78a351 commit 59dc7da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Config struct {
HubImageNamePrefix string `properties:"hub.image.name.prefix,default="`
RyukDisabled bool `properties:"ryuk.disabled,default=false"`
RyukPrivileged bool `properties:"ryuk.container.privileged,default=false"`
RyukUserNamespace string `properties:"ryuk.container.user.namespace,default="`
RyukReconnectionTimeout time.Duration `properties:"ryuk.reconnection.timeout,default=10s"`
RyukConnectionTimeout time.Duration `properties:"ryuk.connection.timeout,default=1m"`
RyukVerbose bool `properties:"ryuk.verbose,default=false"`
Expand Down Expand Up @@ -73,6 +74,11 @@ func read() Config {
config.RyukPrivileged = ryukPrivilegedEnv == "true"
}

ryukUserNamespaceEnv := os.Getenv("TESTCONTAINERS_RYUK_CONTAINER_USER_NAMESPACE")
if ryukUserNamespaceEnv != "" {
config.RyukUserNamespace = ryukUserNamespaceEnv
}

ryukVerboseEnv := os.Getenv("TESTCONTAINERS_RYUK_VERBOSE")
if parseBool(ryukVerboseEnv) {
config.RyukVerbose = ryukVerboseEnv == "true"
Expand Down
1 change: 1 addition & 0 deletions reaper.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ func newReaper(ctx context.Context, sessionID string, provider ReaperProvider) (
WaitingFor: wait.ForListeningPort(listeningPort),
Name: reaperContainerNameFromSessionID(sessionID),
HostConfigModifier: func(hc *container.HostConfig) {
hc.UsernsMode = container.UsernsMode(tcConfig.RyukUserNamespace)
hc.AutoRemove = true
hc.Binds = []string{dockerHostMount + ":/var/run/docker.sock"}
hc.NetworkMode = Bridge
Expand Down

0 comments on commit 59dc7da

Please sign in to comment.