testcontainers / testcontainers/testcontainers-java

[Bug]: Unable to mount a file from test host into a running container. Using Podman on macOS with x86

Abierto
#7,241 5 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

client/podman type/bug
Lenguaje dominante
Java
Estrellas
8.7k
Forks
1.9k
Merge medio
2 d 17 h
PR fusionados (30 d)
9

Descripción

Module

Core

Testcontainers version

1.18.3

Using the latest Testcontainers version?

Yes

Host OS

MacOS Ventura 13.4.1

Host Arch

x86

Docker version
Client:       Podman Engine
Version:      4.5.1
API Version:  4.5.1
Go Version:   go1.20.4
Git Commit:   9eef30051c83f62816a1772a743e5f1271b196d7
Built:        Fri May 26 16:10:12 2023
OS/Arch:      darwin/amd64

Server:       Podman Engine
Version:      4.5.1
API Version:  4.5.1
Go Version:   go1.20.4
Built:        Fri May 26 18:58:48 2
What happened?

Starting a container using Podman run command in terminal I can mount volumes OK. Attempting to do the same in code like:

new GenericContainer<>(imageRepo + ":" + imageTag)
                .withFileSystemBind("./myMount", "/myMount", BindMode.READ_WRITE)
                .withExposedPorts(9080)
                .withPrivilegedMode(true)
                .withLogConsumer(new Slf4jLogConsumer(LOGGER).withPrefix("Service"));
container.start();

Without the withFileSystemBind it starts OK. With it I get this error in log always:

Unable to mount a file from test host into a running container. This may be a misconfiguration or limitation of your Docker environment. Some features might not work.

I can see that in DockerClientFactory method checkMountableFile it attempts to bind a dummy volume and catches any exception. It then only does log.debug of the message including the exception so I can't see the cause.

How can I get the debug output? Does the Slf4jLogConsumer not capture it?

I am using gradle to build and run tests.

Relevant log output
[Test worker] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Loaded org.testcontainers.dockerclient.UnixSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first
    [Test worker] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Found Docker environment with local Unix socket (unix:///var/run/docker.sock)
    [Test worker] INFO org.testcontainers.DockerClientFactory - Docker host IP address is localhost
    [Test worker] INFO org.testcontainers.DockerClientFactory - Connected to docker: 
      Server Version: 4.5.1
      API Version: 1.41
      Operating System: fedora
      Total Memory: 7928 MB
    [Test worker] INFO tc.testcontainers/ryuk:0.5.1 - Creating container for image: testcontainers/ryuk:0.5.1
    [Test worker] INFO tc.testcontainers/ryuk:0.5.1 - Container testcontainers/ryuk:0.5.1 is starting: f6dd9d65d39cdb7749b31b5a9589e8898e3a30022f82534b67243b479327ae63
    [Test worker] INFO tc.testcontainers/ryuk:0.5.1 - Container testcontainers/ryuk:0.5.1 started in PT1.975S
    [Test worker] INFO org.testcontainers.utility.RyukResourceReaper - Ryuk started - will monitor and terminate Testcontainers containers on JVM exit
    [Test worker] INFO org.testcontainers.DockerClientFactory - Checking the system...
    [Test worker] INFO org.testcontainers.DockerClientFactory - ✔︎ Docker server version should be at least 1.6.0
    [Test worker] INFO tc.myImage:latest - Creating container for image: myImage:latest
    [Test worker] WARN tc.myImage:latest - Unable to mount a file from test host into a running container. This may be a misconfiguration or limitation of your Docker environment. Some features might not work.
Additional Information

testcontainers.properties:

docker.client.strategy=org.testcontainers.dockerclient.UnixSocketClientProviderStrategy
ryuk.container.privileged=true

ls -l /var/run | grep docker:

lrwxr-xr-x  1 root             daemon             61 Jun 27 08:19 docker.sock -> /Users/myUser/.local/share/containers/podman/machine/podman.sock

Podman desktop 1.1.0

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza en DockerClientFactory.checkMountableFile y revisa cómo se registra la comprobación fallida del bind-volume. Compara esa ruta con Slf4jLogConsumer y la configuración del registro de pruebas de Gradle para determinar dónde está disponible la excepción subyacente. Se considera terminado cuando la causa del fallo de montaje puede observarse al reproducir el problema con Podman en macOS.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
docker, java
Área
devops, testing-qa
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.