Visitar URL original
Add pause() and unpause() to started containers by artbom · Pull Request #1633 · testcontainers/testcontainers-node · GitHub
Skip to content

Add pause() and unpause() to started containers - #1633

Open
artbom wants to merge 2 commits into
testcontainers:mainfrom
artbom:pause-unpause-kill
Open

artbom wants to merge 2 commits into
testcontainers:mainfrom
artbom:pause-unpause-kill

Conversation

@artbom

@artbom artbom commented Nov 4, 2026 •

Copy link
Copy Markdown

Summary

Started containers get pause() and unpause(), so tests for reconnects, failover and timeouts can freeze a container without going through Dockerode.

ContainerClient gets the matching two methods, and StartedGenericContainer calls them. AbstractStartedContainer forwards both, so module containers pick them up with no changes. The docs get a short "Pausing a container" section.

I dropped kill() after review. stop() already kills by default, a killed container would still look started until #1545 and #1541 land, and no other Testcontainers implementation has it.

Verification

generic-container-pause.test.ts pauses the container and checks that inspect reports State.Paused as true. It then unpauses it and checks that State.Paused is false again and the container serves HTTP. The test fails before the change with container.pause is not a function and passes after it. The existing restart tests still pass, and npm run format, npm run lint, npm run knip and npm run check-compiles are clean.

Not breaking

The change only adds methods. Code that implements StartedTestContainer or ContainerClient by hand, instead of extending AbstractStartedContainer, would need the two new methods. Every module in this repo extends AbstractStartedContainer, so none of them change.

Closes #1549

@cristianrgreco

Copy link
Copy Markdown
Collaborator

Thanks for this! Let's keep pause()/unpause() and drop kill():

Could you remove kill from StartedTestContainer, ContainerClient, DockerContainerClient, StartedGenericContainer and AbstractStartedContainer, along with its two tests, and rename the docs section to "Pausing a container" without the kill lines?

@cristianrgreco cristianrgreco added enhancement New feature or request minor Backward compatible functionality labels Nov 6, 2026
stop() already kills by default, a killed container still looks started until testcontainers#1545 and testcontainers#1541 land, and no other Testcontainers implementation has kill().
@artbom artbom changed the title Add pause(), unpause() and kill() to started containers Add pause() and unpause() to started containers Nov 9, 2026
@artbom

artbom commented Nov 9, 2026

Copy link
Copy Markdown
Author

Thanks for this! Let's keep pause()/unpause() and drop kill():

Could you remove kill from StartedTestContainer, ContainerClient, DockerContainerClient, StartedGenericContainer and AbstractStartedContainer, along with its two tests, and rename the docs section to "Pausing a container" without the kill lines?

done @cristianrgreco

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request minor Backward compatible functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add pause(), unpause() and kill() to started containers

2 participants