@Test
    public void customLabelTest() {
        try (
            final GenericContainer alpineCustomLabel = new GenericContainer<>(TestImages.ALPINE_IMAGE)
                .withLabel("our.custom", "label")
                .withCommand("top")
                .withCreateContainerCmdModifier(cmd -> cmd.getLabels().put("scope", "local"))
        ) {
            alpineCustomLabel.start();

            Map<String, String> labels = alpineCustomLabel.getCurrentContainerInfo().getConfig().getLabels();
            assertThat(labels).as("org.testcontainers label is present").containsKey("org.testcontainers");
            assertThat(labels).as("org.testcontainers.lang label is present").containsKey("org.testcontainers.lang");
            assertThat(labels)
                .as("org.testcontainers.lang label is present")
                .containsEntry("org.testcontainers.lang", "java");
            assertThat(labels)
                .as("org.testcontainers.version label is present")
                .containsKey("org.testcontainers.version");
            assertThat(labels).as("our.custom label is present").containsKey("our.custom");
            assertThat(labels).as("our.custom label value is label").containsEntry("our.custom", "label");
            assertThat(labels)
                .as("project label value is testcontainers-java")
                .containsEntry("project", "testcontainers-java");
            assertThat(labels).as("scope label value is local").containsEntry("scope", "local");
        }
    }
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