Skip to content

Resource.Expire() incompatible with Podman #628

@akselaase

Description

@akselaase

Preflight checklist

Ory Network Project

No response

Describe the bug

Resource.Expire() as implemented by #133 causes issues when using Podman as the container management tool.

The issues is that Resource.Expire() will immediately cause the container to enter the "Stopping" state (as can be seen in podman ps -a). Podman then disallows any further exec operations on the container, as that requires the container to be in state "Running" (as seen here: https://github.com/containers/podman/blob/7c9d4a42c54b685a3c47ee2200d2bf3811fb5b03/libpod/container_exec.go#L231-L233).

This makes it impossible to launch further commands in a container after Expire() has been called.

Reproducing the bug

Requires enabling the systemd unit podman.socket and pointing DOCKER_HOST to the socket.

pool, _ := dockertest.NewPool("")
resource, _ := pool.Run("postgres", "16-alpine", []string{
	"POSTGRES_PASSWORD=pass",
	"POSTGRES_USER=user",
})
resource.Expire(300)

// This fails due to the container being in state "Stopping"
exitCode, _ := resource.Exec(
	[]string{
		"psql",
		"-U", "user",
		"-c", "CREATE ROLE \"[email protected]\" WITH LOGIN;",
	},
	dockertest.ExecOptions{
		Env:    []string{"PGPASSWORD=pass"},
		StdOut: os.Stdout,
		StdErr: os.Stderr,
	},
)

Relevant log output

podman[48951]: time="2026-01-14T11:16:33+01:00" level=info msg="Request Failed(Internal Server Error): can only create exec sessions on running containers: container state improper"

Relevant configuration

Version

dockertest v3.11.0

On which operating system are you observing this issue?

None

In which environment are you deploying?

None

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions