Skip to content

NullPointerException in execInContainer for long running commands #4453

Description

@bgranvea

Test case:

    @Test
    public void testExecInContainer() throws InterruptedException, IOException {
        try (GenericContainer<?> c = new GenericContainer<>(DockerImageName.parse("redis:3.0.2"))) {
            c.start();
            Container.ExecResult r = c.execInContainer("/bin/bash", "-c", "sleep 600");
        }
    }

After 3 minutes, I've got this exception (tested with testcontainers 1.16.0):

java.lang.NullPointerException
	at org.testcontainers.containers.ExecInContainerPattern.execInContainer(ExecInContainerPattern.java:85)
	at org.testcontainers.containers.ContainerState.execInContainer(ContainerState.java:235)
	at org.testcontainers.containers.ContainerState.execInContainer(ContainerState.java:226)

Note: I'm using DOCKER_HOST to execute on a Linux machine.

My real problem is: how do I execute a command which runs a long time? there seems to be an underlying socket timeout in docker-java, is it possible to increase this timeout?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions