testcontainers / testcontainers/testcontainers-java

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

オープン
#7,241 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

client/podman type/bug
主要言語
Java
スター
8.7k
フォーク
1.9k
平均マージ
2日 17時間
マージ済み PR(30日)
9

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

DockerClientFactory.checkMountableFile から開始し、失敗した bind-volume チェックがどのようにログに記録されるかを確認します。その経路を Slf4jLogConsumer および Gradle のテストロギング設定と比較し、基になる例外がどこで利用可能かを特定します。Podman を使って macOS 上で問題を再現した際に、マウント失敗の原因を確認できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
docker, java
領域
devops, testing-qa
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。