testcontainers / testcontainers/testcontainers-java

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

Aperta
#7,241 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

client/podman type/bug
Lingua principale
Java
Stelle
8.7k
Fork
1.9k
Merge medio
2g 17h
PR unite (30g)
9

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da DockerClientFactory.checkMountableFile e verifica come viene registrato il controllo fallito del bind-volume. Confronta quel percorso con Slf4jLogConsumer e la configurazione del logging dei test di Gradle per determinare dove è disponibile l’eccezione sottostante. Il lavoro è completato quando la causa del fallimento del mount può essere osservata riproducendo il problema con Podman su macOS.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
docker, java
Ambito
devops, testing-qa
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.