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

Make it possible to obtain a reference of type Container to services started by Docker Compose #2302

Closed
bsideup opened this issue Jan 28, 2020 · 1 comment · Fixed by #2314

Comments

@bsideup
Copy link
Member

bsideup commented Jan 28, 2020

Since DockerComposeContainer#project is private, there is currently no way of accessing containers started by Docker Compose.

We should add a public API to access them, something like:

public ContainerState getServiceContainer(String serviceId);

We already do something similar here:

private List<Container> listChildContainers() {
return dockerClient.listContainersCmd()
.withShowAll(true)
.exec().stream()
.filter(container -> Arrays.stream(container.getNames()).anyMatch(name ->
name.startsWith("/" + project)))
.collect(toList());
}

And store it in:
private final Map<String, ComposeServiceWaitStrategyTarget> serviceInstanceMap = new ConcurrentHashMap<>();

Which means that the implementation should be a simple look up.

This will also solve #1916 and similar requests.

@artjomka
Copy link
Contributor

artjomka commented Jan 29, 2020

I would like to work on this issue, if its not taken already

bsideup pushed a commit that referenced this issue Feb 9, 2020
Since `DockerComposeContainer#project` is private, there is currently no way of accessing containers started by Docker Compose.

This change adds a new API to the DockerComposeContainer to obtain a `ContainerState` reference by the service's name.

Fixes #2302.
@bsideup bsideup modified the milestones: next, 1.13.0 Mar 10, 2020
quincy pushed a commit to quincy/testcontainers-java that referenced this issue May 28, 2020
)

Since `DockerComposeContainer#project` is private, there is currently no way of accessing containers started by Docker Compose.

This change adds a new API to the DockerComposeContainer to obtain a `ContainerState` reference by the service's name.

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

Successfully merging a pull request may close this issue.

2 participants