Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem mounting volumes after revamp #580

Closed
ns-sjorgedeaguiar opened this issue Apr 23, 2024 · 1 comment · Fixed by #581
Closed

Problem mounting volumes after revamp #580

ns-sjorgedeaguiar opened this issue Apr 23, 2024 · 1 comment · Fixed by #581

Comments

@ns-sjorgedeaguiar
Copy link
Contributor

Hi, I was testing the new version after #575 and mounting is not working with custom images.

The problem seems to be because the runner sets the volumes config option:

// volumes
let vols: HashMap<String, HashMap<(), ()>> = runnable_image
    .volumes()
    .map(|(orig, dest)| (format!("{orig}:{dest}"), HashMap::new()))
    .collect();
config.volumes = Some(vols);

However that option is meant for anonymous volume mounts, where the keys are the path inside the container and the values are an empty map.
The binds hostconfig option is the one accepting a list of mounts. Replacing the above by something like this works:

// volumes
let binds: Vec<String> = runnable_image
    .volumes()
    .map(|(orig, dest)| format!("{orig}:{dest}"))
    .collect();
if !binds.is_empty() {
    config.host_config = config.host_config.map(|mut host_config| {
        host_config.binds = Some(binds);
        host_config
    });
}
@DDtKey
Copy link
Collaborator

DDtKey commented Apr 23, 2024

Thanks for reporting!

Yeah, this should be fixed.

Interestingly, no one has used an http client with volumes before (that part hasn't actually been changed).
Anyway, the issue is pretty straightforward.

Feel free to open PR if you wish. Otherwise I'll address this a bit later

ns-sjorgedeaguiar added a commit to ns-sjorgedeaguiar/testcontainers-rs that referenced this issue Apr 23, 2024
The volumes option is used for anonymous volumes, whereas the
binds is the one that accepts a list of `{local}:{remote}` paths.

Fixes testcontainers#580.
ns-sjorgedeaguiar added a commit to ns-sjorgedeaguiar/testcontainers-rs that referenced this issue Apr 23, 2024
The volumes option is used for anonymous volumes, whereas the
binds is the one that accepts a list of `{local}:{remote}` paths.

Fixes testcontainers#580.
github-merge-queue bot pushed a commit that referenced this issue Apr 23, 2024
The volumes option is used for anonymous volumes, whereas the binds is
the one that accepts a list of `{local}:{remote}` paths.

Fixes #580.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants