getContainerByServiceName expects an instance name
#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?
I got hit by the same problem. To solve this I had to clone the private method getServiceInstanceName(String serviceName) to get the service instance name for a service name. I have no idea how I can get the service instance name in any other way.
getServicePort() calls getServinceInstanceName in internally and therefore it works with both.