dotnet / sdk-container-builds

Libraries and build tooling to create container images from .NET projects using MSBuild
https://learn.microsoft.com/en-us/dotnet/core/docker/publish-as-container
MIT License
175 stars 30 forks source link

How to run docker commands #542

Open lymberl opened 5 months ago

lymberl commented 5 months ago

How would i run the following docker command before the ENTRYPOINT using the SDK Container Building Tools? But this is to basically set the image to use TLS v1.2 or below for the default .NET8 image (.NET8 Issue).

RUN sed -i '/[openssl_init]/a ssl_conf = ssl_sect' /etc/ssl/openssl.cnf

or

RUN sed -i '/[openssl_init]/a ssl_conf = ssl_sect' /etc/ssl/openssl.cnf RUN printf "\n[ssl_sect]\nsystem_default = system_default_sect\n" >> /etc/ssl/openssl.cnf RUN printf "\n[system_default_sect]\nMinProtocol = TLSv1.2\nCipherString = DEFAULT@SECLEVEL=0" >> /etc/ssl/openssl.cnf

baronfel commented 5 months ago

You can set your own Entrypoint script + args with the ContainerAppCommand items - though another pathway would be to modify the SSL Conf file and mount that in during container execution via -v commands.

In general, the SDK Containers tech does not support RUN commands and cannot because it doesn't run a Linux VM, so we have to find alternative ways to accomplish the same goal.

lymberl commented 5 months ago

Hello,

Can you point to a sample of how to do an Entrypoint script with the args and ContainerAppCommand? And I will test to see if this works.

On Fri, Jan 26, 2024 at 12:48 PM Chet Husk @.***> wrote:

You can set your own Entrypoint script + args with the ContainerAppCommand https://github.com/dotnet/sdk-container-builds/blob/main/docs/ContainerCustomization.md#containerappcommand items - though another pathway would be to modify the SSL Conf file and mount that in during container execution via -v commands.

In general, the SDK Containers tech does not support RUN commands and cannot because it doesn't run a Linux VM, so we have to find alternative ways to accomplish the same goal.

— Reply to this email directly, view it on GitHub https://github.com/dotnet/sdk-container-builds/issues/542#issuecomment-1912527210, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH7YYRGJNVRDFPHLYO7Y4OLYQP26RAVCNFSM6AAAAABCKBK676VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJSGUZDOMRRGA . You are receiving this because you authored the thread.Message ID: @.***>

lymberl commented 5 months ago

I have added the following to the csproj file but it doesnt run the script `

<ContainerAppCommand Include="bash" />

` and when i inspect the container it lists the following. It seems to also add the dotnet and dll as arguments even though i have not specified them. `"Path": "bash", "Args": [ "dotnet", "dotnetApp.dll", "containersetupscript.sh" ]` The logs end up displaying /usr/bin/dotnet: /usr/bin/dotnet: cannot execute binary file
lymberl commented 5 months ago

if you add `

<ContainerAppCommand Include="echo" />

` it will display _dotnet dotnetApp.dll containersetupscript.sh._ So it is adding dotnet and the dll name as arguments to the command which seems to be a bug.
clement128 commented 3 months ago

@baronfel Can you be more specified or give an example? thanks in advance.