testcontainers-rs icon indicating copy to clipboard operation
testcontainers-rs copied to clipboard

No such file or directory error when looking for docker compose files

Open vonjackets opened this issue 3 months ago • 3 comments

Hey all, I'm trying to use the latest changes (as of 9aae21e7330f3ad22a7742c82dd5eea465928510) to leverage the docker compose support, but I'm having a wild error I can't figure out.

I'm trying to simply run a provided docker compose file, but I get this error constantly using even the simplest code and file tree.

It should be stated that my intel macos system is running podman version 5.4.1 instead of docker (with docker compatibility enabled) but I haven't had much trouble getting regular containers to run using the library, so I can't be sure what the problem could be? I intend to dig further, but I'd appreciate any feedback.

Compose

services:
  neo4j:
    user: 7474:7474
    image: neo4j:5.26.2
    restart: never
    environment:
      - NEO4J_AUTH=neo4j/somepassword
    ports:
      - "7474:7474"
      - "7687:7687"

file tree:

├── Cargo.lock
├── Cargo.toml
├── docker-compose.yaml
└── src
    └── main.rs
use testcontainers::compose::DockerCompose;

#[tokio::main]
async fn main() {
    let mut compose = DockerCompose::with_local_client(&["docker-compose.yml"]);
    compose.up().await.expect("expected to start");
}

error:


thread 'main' panicked at src/main.rs:6:24:
expected to start: Testcontainers(Io(Os { code: 2, kind: NotFound, message: "No such file or directory" }))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
                                                                                    

vonjackets avatar Nov 24 '25 03:11 vonjackets

Hi @vonjackets 👋

In the details you've shared I see that file is .yaml, but test specifies .yml

Also you always can try to use CARGO_MANIFEST_DIR like:

        let path_to_compose = PathBuf::from(format!(
            "{}/docker-compose.yaml",
            env!("CARGO_MANIFEST_DIR")
        ));

DDtKey avatar Nov 25 '25 15:11 DDtKey

Hi @vonjackets 👋

Let me know if we can close the issue.

DDtKey avatar Nov 29 '25 21:11 DDtKey

Hey sorry my notification got lost. I'll give this a try this week! Thus could very well be an oops on my part

vonjackets avatar Nov 29 '25 22:11 vonjackets

Feel free to reopen if it doesn't work for you!

Generally example above should work just fine as I have such workflows working.

DDtKey avatar Dec 19 '25 04:12 DDtKey