How do I specify a range of ports like -p 5080-5090:5080-5090?
#1386
Unanswered
Swimburger
asked this question in
Q&A
Replies: 1 comment 2 replies
-
|
I'm afraid that's not supported out of the box. We can add it without much effort, but I'm curious, would you expect this to work with random host ports? We don't recommend using static port bindings since they don't support parallelization and might conflict with other services running on the host (especially when working with others). You could probably work around the missing API like this: var containerBuilder = Enumerable.Range(5080, 10)
.Aggregate(new ContainerBuilder().WithImage("alpine:3.17"),
(builder, port) => builder.WithPortBinding(port, port));
var container = containerBuilder.Build(); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I need to specify a range of ports like the docker command lets you do
-p 5080-5090:5080-5090.I tried the following:
Which gives this error:
Unhandled exception. Docker.DotNet.DockerApiException: Docker API responded with status code=BadRequest, response={"message":"invalid port specification: \"5080-5090\""} at Docker.DotNet.DockerClient.HandleIfErrorResponseAsync(HttpStatusCode statusCode, HttpResponseMessage response, IEnumerable`1 handlers) in /_/src/Docker.DotNet/DockerClient.cs:line 492 at Docker.DotNet.DockerClient.MakeRequestAsync[T](IEnumerable`1 errorHandlers, HttpMethod method, String path, IQueryString queryString, IRequestContent body, IDictionary`2 headers, TimeSpan timeout, CancellationToken token) in /_/src/Docker.DotNet/DockerClient.cs:line 257 at Docker.DotNet.ContainerOperations.CreateContainerAsync(CreateContainerParameters parameters, CancellationToken cancellationToken) in /_/src/Docker.DotNet/Endpoints/ContainerOperations.cs:line 64 at DotNet.Testcontainers.Clients.DockerContainerOperations.RunAsync(IContainerConfiguration configuration, CancellationToken ct) in /_/src/Testcontainers/Clients/DockerContainerOperations.cs:line 225 at DotNet.Testcontainers.Clients.TestcontainersClient.RunAsync(IContainerConfiguration configuration, CancellationToken ct) in /_/src/Testcontainers/Clients/TestcontainersClient.cs:line 339 at DotNet.Testcontainers.Containers.DockerContainer.UnsafeCreateAsync(CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 454 at DotNet.Testcontainers.Containers.DockerContainer.StartAsync(CancellationToken ct) in /_/src/Testcontainers/Containers/DockerContainer.cs:line 298 at PineconeLocalRepro.Program.Main(String[] args) in /Users/niels/RiderProjects/ConsoleApp2/ConsoleApp2/Program.cs:line 21 at PineconeLocalRepro.Program.<Main>(String[] args)And I tried
.WithPortBinding("5080-5090:5080-5090")which gave the same error.How would I go about this?
Beta Was this translation helpful? Give feedback.
All reactions