Docker container start unlimited loop and window data full after some minutes its in run

50 Views Asked by At

I create a simple hello-world image with console application c# in docker but when run the container its created unlimited loop!

Hellow("n", out string result);

while (result != "y")
{
    Hellow(result, out result);
}

Environment.Exit(0);

static void Hellow(string entery, out string result)
{
    Console.Clear();
    Console.WriteLine("Hello, World!");

    if (entery != "n")
    {
        Console.WriteLine(string.Format("{0} is not a correct Argument", entery));
        Question(out result);
    }
    else Question(out result);
}

static void Question(out string result)
{
    Console.WriteLine();
    Console.Write("Are you want to stop container? [y/N] ");
    result = Console.ReadLine()?.ToLower()!;
}

Dockerfile

FROM mcr.microsoft.com/dotnet/runtime:6.0 As base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:6.0 As build
WORKDIR /src
COPY *.sln ./
COPY *.csproj ./
RUN dotnet restore
COPY . .

FROM build As publish
WORKDIR /src/
RUN dotnet publish -c Release -o /app

FROM base As final
WORKDIR /app
COPY --from=publish /app/ .
CMD [ "dotnet", "dotnet-Test.dll" ]

Run project without docker was successful but when I run below command every thing was happened

docker run --name hellow -v temp-file:/app/temp -it hello-world

First create unlimited loop and cpu is very usage with container but I don't be careful and just close cmd and comeback to my work

I try to create, write and read file in volume folder like my education video(In video use another application for image) but shell doesn't let me to read and write in volume folder and suddenly docker container stopped and image not to see in image section.

I quite the docker and then I see just 3 gig free in my disk before 40 gig was free!

What is my mistake in docker usage?

And Why did this happen?

Note : I use linux subsystem to development in windows 10 and when I can't to read and write file i send some data in this community Ask Ubuntu

0

There are 0 best solutions below