I need to set restart policy --restart unless-stopped for my Docker container.
I'm using Dockerfile to configure container with next example content:
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY . ./
ENTRYPOINT ["asd", "proj.dll"]
And using Docker.DotNet to launch containers with next example code:
container.StartContainerAsync(container.ID, null);
How to set that policy in that case?
Perhaps I can use ContainerStartParameters somehow?
Via Dockerfile: You can't. It's just impossible.
Via Docker.Dotnet You can set restart policy with following code: