@Test
    public void withTmpFsTest() throws Exception {
        try (
            GenericContainer<?> container = new GenericContainer<>(TestImages.TINY_IMAGE)
                .withCommand("top")
                .withTmpFs(Collections.singletonMap("/testtmpfs", "rw"))
        ) {
            container.start();
            // check file doesn't exist
            String path = "/testtmpfs/test.file";
            Container.ExecResult execResult = container.execInContainer("ls", path);
            assertThat(execResult.getStderr())
                .as("tmpfs inside container works fine")
                .isEqualTo("ls: /testtmpfs/test.file: No such file or directory\n");
            // touch && check file does exist
            container.execInContainer("touch", path);
            execResult = container.execInContainer("ls", path);
            assertThat(execResult.getStdout()).as("tmpfs inside container works fine").isEqualTo(path + "\n");
        }
    }
Create a container with an extra host entry and expose the content of /etc/hosts for testing.
core/src/test/java/org/testcontainers/junit/GenericContainerRuleTest.java