mariotoffia / FluentDocker

Use docker, docker-compose local and remote in tests and your .NET core/full framework apps via a FluentAPI
Apache License 2.0
1.31k stars 97 forks source link

Container Names with Underscores #270

Open cord-agencyroot opened 2 years ago

cord-agencyroot commented 2 years ago

Not sure if this is actually said anywhere, but I was having a terrible time trying to get the wait to properly work with docker-compose.

None of the 'wait' lambda breakpoints where being hit, here is an example:

  compositeBuilder.Wait("postgres_projectname", (service, _) =>
        {
            service.WaitForMessageInLogs("listening on IPv4 address", 30000L);
            return 0;
        });

Placing a breakpoint inside the lambda would never stop at the "WaitForMessageInLogs" line.

  postgres_projectname:
    container_name: postgres_projectname
    environment:
      POSTGRES_USER: postgressql
      POSTGRES_PASSWORD: postgressql
      POSTGRES_DB: postgressql
    image: postgres:14-alpine
    ports:
      - "5432:5432"

Turns out it was because I had _ (underscore) character for my container names, seems like it causes FluentDocker to ignore the wait (or doesn't find a match) when building.

Change my container name to 'postgres-projectname' seemed to fix the issue

Not sure if this is a bug or working as intended, but it would be nice to get some sort of notification/warning with using _ as a name. Hopefully this helps someone if they come across the same issue.

Note: This may be more of a docker limitation than an issue with FluentDocker, but hopefully this helps someone

mariotoffia commented 2 years ago

Hi @cord-agencyroot, thanks for the bug report and the workaround!