testcontainers / testcontainers/testcontainers-java

[Enhancement]: Create volumes for testcontainers

Open
#7,420 8 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type/enhancement
Dominant language
Java
Stars
8.7k
Forks
1.9k
Avg merge
2d 17h
Merged PRs (30d)
9

Description

Module

Core

Proposal

I recently needed to create two test containers that shared data storage. One container would generate data, and the second would read this data. My first thought was to create a docker volume and share the volume in the two containers. This avoids bind mounts which complicates things greatly. Bind mounts are harder to make work cross platform and there are restrictions on bind mounts when I run in my CI tool, bitbucket pipelines.

However, I cannot find any way to do this with testcontainers. There is a way to use withVolumesFrom but there is no way to create the volume as best I can tell. Here is an example of what I was trying to do with test containers but shown with docker commands.

Create a first container with a annonymous volume:
docker run -it --rm --name source --volume=/share ubuntu bash

Create a second container that uses the same volume from the first:
docker run -it --rm --volumes-from source --name dest ubuntu bash

Then in the source container I write a file into the /share directory and I can cat it out in the dest container. I would like to set this up using test containers.

Thanks for this great tool!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the Core module by tracing the existing withVolumesFrom support and the container configuration APIs. Compare them with Docker's volume and --volumes-from behavior described in the issue. Done means users can create a volume and share it between two test containers so data written by one can be read by the other.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java
Domain
testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.