FluentDocker icon indicating copy to clipboard operation
FluentDocker copied to clipboard

docker containers with multiple hyphens in the name

Open cord-agencyroot opened this issue 4 months ago • 1 comments

Just something I noticed in the latest release (thank you for updating it to support the new docker compose!).

I have a WaitForLogs for a specific message.

 return builder.Wait(serviceName, (service, _) =>
        {
            service.WaitForMessageInLogs(message, timeout);
            return 0;
        });

If my docker container name is like this:

  postgres:
    container_name: some-container-postgres
    environment:
      POSTGRES_USER: postgresql
      POSTGRES_PASSWORD: postgresql
      POSTGRES_DB: postgresql
    image: "postgres:latest"
    ports:
      - "5432:5432"

It doesn't wait for the log.

however, this works just fine. Not sure what's going on exactly, but seems like the extra - in the container name is throwing something off on the wait command.

  postgres:
    container_name: some-postgres
    environment:
      POSTGRES_USER: postgresql
      POSTGRES_PASSWORD: postgresql
      POSTGRES_DB: postgresql
    image: "postgres:latest"
    ports:
      - "5432:5432"

cord-agencyroot avatar Sep 23 '25 13:09 cord-agencyroot

It looks like a parsing issue somewhere. Using this compose file:

services:
  prefix-nginx-abcd:
    image: nginx:latest
    ports:
      - "8080:80"
    restart: always

and this code:

using Ductus.FluentDocker.Builders;

const string file = "docker-compose.yaml";

using (var svc = new Builder()
    .UseContainer()
    .UseCompose()
    .FromFile(file)
    .Build()
    .Start())
{
    foreach (var container in svc.Containers)
    {
        Console.WriteLine($"Service: {container.Service}, Name: {container.Name}, InstanceId: {container.InstanceId}, Id: {container.Id}");
    }
}

I get this output in v2.79.0

Service: incorrectidexample, Name: incorrectidexample-prefix-nginx-abcd-1, InstanceId: 1, Id: dd516ed436d14a6dbafdc13df453eb08779673abbcbfdb1f104e1b0ca8e32f84

and this output in v2.80.0 and v2.85.0

Service: incorrectidexample, Name: prefix, InstanceId: nginx, Id: c0909ba63c8da3761cfe284db1602ebd914dc6b9aaf55ba8c3e96365d97f79c7

gregington avatar Nov 27 '25 01:11 gregington