Closed Crumbler closed 7 months ago
I think you are using incorrect paths. The build context, respectively the paths inside the Dockerfile
, look wrong. The log message says:
COPY failed: file not found in build context or excluded by .dockerignore: stat ContainerTest/ContainerTest.csproj: file does not exist
Which makes sense, because your build context (root directory being F:\My projects\ContainerTest\ContainerTest\
) does not contain ContainerTest\ContainerTest.csproj
. The correct copy instruction path is ContainerTest.csproj
.
Move the Dockerfile
to your solution file directory and set the Dockerfile
root directory to WithDockerfileDirectory(CommonDirectoryPath.GetSolutionDirectory(), string.Empty)
instead.
@HofmeisterAn Huge thanks to you. I've edited the Dockerfile and now everything works as intended. I've realized that Visual Studio uses the Solution folder as the build context by default.
👍 I have seen similar issues with VS's generated configuration before. I definitely need to take a look into the configuration VS generates. Maybe we can support it out of the box in Testcontainers.
Testcontainers version
3.6.0
Using the latest Testcontainers version?
Yes
Host OS
Windows 10 Pro 19045.3803
Host arch
Intel x64
.NET version
8.0.100
Docker version
Docker info
What happened?
I have an ASP.NET Core 8 Web API project with a dockerfile in it. Building an image using ImageFromDockerfileBuilder fails due to being unable to copy the project file (see log below). The dockerfile is generated automatically by Visual Studio 2022.
Building the docker image using the Docker CLI works just fine, and so does starting the container via Visual Studio using the Docker profile from launchSettings.json.
Steps to reproduce this behavior (using Visual Studio 2022):
Relevant log output
Additional information
Sample project: https://github.com/Crumbler/ContainerTest