Skip to content

Conversation

@slang25
Copy link
Contributor

@slang25 slang25 commented Nov 1, 2025

Fixes #13

My understanding is that the hostname localstack should be using should be consistent with it's external endpoint, so I think this change makes sense.

@slang25 slang25 force-pushed the fix-persistent-container branch from 6fbb270 to 56db39e Compare November 1, 2025 23:20
@nazarii-piontko
Copy link
Contributor

nazarii-piontko commented Nov 2, 2025

I encountered the same issue. I think there’s a simpler and more portable fix for it.

Currently, AddLocalStack contains this line:

.WithHttpEndpoint(targetPort: Constants.DefaultContainerPort, name: LocalStackResource.PrimaryEndpointName)

To resolve the issue, it should be enough to explicitly pass the port parameter, for example:

.WithHttpEndpoint(targetPort: Constants.DefaultContainerPort, port: Constants.DefaultContainerPort, name: LocalStackResource.PrimaryEndpointName)

Alternatively, the port could be provided as part of LocalStackContainerOptions.

I ran some local tests, and this approach works correctly. Additionally, passing the port from the configuration helps prevent random port changes between runs, which is especially important when running the CLI.

@nazarii-piontko
Copy link
Contributor

I have prepared another PR for this issue: #15

@slang25 slang25 closed this Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ContainerLifetime.Persistent doesn't seem to re-use the container

2 participants