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

[Enhancement]: Expose configuration of ExposeHostPortsAsync container PortForwardingContainer #1331

Open
Muchaszewski opened this issue Jan 7, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@Muchaszewski
Copy link

Problem

I want to configure PortForwardingContainer so that I can add custom logger to the TestContainer that is used by ExposeHostPortsAsync.

Current code:

await TestcontainersSettings.ExposeHostPortsAsync(3050);

Expected code:

await PortForwardingSettings.Configure(builder =>
        {
            var logger = GetLogger<PortForwardingContainer>();
            return builder
                .WithLogger(logger);
        }).ExposeHostPortsAsync(3050);

Solution

Proposed solutions:

  1. Expose PortForwardingContainer from internal to public so that configuration can be made on a instance, and split Instance from Build so that builder can be preconfigured
  2. Expose OptionsBuilder via ExposeHostPortsAsync
  3. Add new endpoint that allows for ConfigureExposeHostPorts

Benefit

I can redirect all the logs and monitor what is happening via logger of my choice

Alternatives

I tried to copy PortForwardingContainer and all necessary classes from the source repository and use them with configuration instead of TestcontainersSettings.ExposeHostPortsAsync but it doesn't seem to be working.

sshd image is created, but /etc/hosts is not modified and there is lack of documentation or code reference on why is that. The only part I changed is to expose the builder part of the container.

Would you like to help contributing this enhancement?

Yes

@Muchaszewski Muchaszewski added the enhancement New feature or request label Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant