testcontainers / testcontainers/testcontainers-java

getContainerByServiceName expects an instance name

Open
#4,281 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

#2314 brought support for selecting a container based on the service name when using docker-compose (thanks 🙌 !). However, the value it expects contains the "container number" (e.g. service_1), instead of just the service name, e.g. just service.

This does not match the behaviour of using docker-compose directly:

$ docker-compose ps agent
      Name             Command       State   Ports
--------------------------------------------------
myapp_agent_1   /bin/k3s agent   Up
$ docker-compose ps agent_1
ERROR: No such service: agent_1

According to this test, it looks like the expected behavior, or maybe was incorrectly modeled.

Maybe using getServiceInstanceName from getContainerByServiceName would provide compatibility for both cases?

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 by reading getContainerByServiceName and the test referenced from pull request #2314, then compare the current lookup with docker-compose ps service-name behavior. Done means the lookup accepts the service name consistently while preserving any intended instance-name compatibility, with the relevant test updated or added.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.