Skip to content

Commit f4d27c0

Browse files
committed
.NET versions < 8.0 want the --urls argument
1 parent dc8141a commit f4d27c0

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

tests/Microsoft.DotNet.Docker.Tests/ImageScenarioVerifier.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ public async Task Execute()
5959
// Use `sdk` image to build and run test app
6060
string buildTag = BuildTestAppImage("build", solutionDir, customBuildArgs);
6161
tags.Add(buildTag);
62-
await RunTestAppImage(buildTag, command: $"dotnet run");
62+
string dotnetRunArgs = _isWeb || _imageData.Version.Major < 8 ? $" --urls http://0.0.0.0:{_imageData.DefaultPort}" : string.Empty;
63+
await RunTestAppImage(buildTag, command: $"dotnet run{dotnetRunArgs}");
6364
}
6465

6566
// Running a scenario of unit testing within the sdk container is identical between a console app and web app,
@@ -74,7 +75,7 @@ public async Task Execute()
7475
// Use `sdk` image to publish FX dependent app and run with `runtime` or `aspnet` image
7576
string fxDepTag = BuildTestAppImage("fx_dependent_app", solutionDir, customBuildArgs);
7677
tags.Add(fxDepTag);
77-
// if we're a webapp on windows
78+
// If we're a web app on Windows, use the ContainerAdministrator account
7879
string fxDepUser = (_isWeb && !DockerHelper.IsLinuxContainerModeEnabled) ? _adminUser : null;
7980
await RunTestAppImage(fxDepTag, user: fxDepUser);
8081

@@ -106,7 +107,7 @@ public async Task Execute()
106107
}
107108
finally
108109
{
109-
// tags.ForEach(tag => _dockerHelper.DeleteImage(tag));
110+
tags.ForEach(tag => _dockerHelper.DeleteImage(tag));
110111
Directory.Delete(solutionDir, true);
111112
}
112113
}
@@ -310,8 +311,6 @@ private void CreateProjectWithSdkImage(string templateName, string destinationPa
310311
_dockerHelper.Copy($"{containerName}:{ProjectContainerDir}", destinationPath);
311312
}
312313

313-
// pass in user instead of boolean for runAsAdmin
314-
// pass admin by default, can pass in app as a special case for testing non-root
315314
private async Task RunTestAppImage(string image, string user = null, string command = null)
316315
{
317316
string containerName = _imageData.GetIdentifier("app-run");
@@ -339,7 +338,7 @@ private async Task RunTestAppImage(string image, string user = null, string comm
339338

340339
public static async Task<HttpResponseMessage> GetHttpResponseFromContainerAsync(string containerName, DockerHelper dockerHelper, ITestOutputHelper outputHelper, int containerPort, string pathAndQuery = null, Action<HttpResponseMessage> validateCallback = null, AuthenticationHeaderValue authorizationHeader = null)
341340
{
342-
int retries = 4;
341+
int retries = 30;
343342

344343
// Can't use localhost when running inside containers or Windows.
345344
string url = !Config.IsRunningInContainer && DockerHelper.IsLinuxContainerModeEnabled

tests/Microsoft.DotNet.Docker.Tests/ProductImageData.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ public ImageVersion VersionFamily
5353

5454
public string VersionString => Version.ToString();
5555

56-
public override int DefaultPort
57-
{
58-
get => (IsDistroless | Version.Major >= 8) ? 8080 : 80;
59-
}
56+
public override int DefaultPort => (IsDistroless | Version.Major >= 8) ? 8080 : 80;
6057

6158
public string GetDockerfilePath(DotNetImageType imageType) =>
6259
$"src/{GetVariantName(imageType)}/{Version}/{OSTag}/{GetArchLabel()}";

0 commit comments

Comments
 (0)