VB.NET application cannot run on Docker

Viewed 51

I have a Dockerfile

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env

and I want to be able to run a simple VB.NET application file main.vb with the code below:

'Program to print "Hello World" in VB.NET.

Module Module1
    
    Sub Main()
        Console.WriteLine("Hello World")
    End Sub
    
End Module

I ran: vbc main.vb but I got the error sh: 1: vbc: not found

Please what do I need to do? It seems it is not possible to run it in my container.

1 Answers

I think your Dockerfile is missing some things.

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
WORKDIR /app

# Copy everything
COPY . ./
# Restore as distinct layers
RUN dotnet restore
# Build and publish a release
RUN dotnet publish -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/sdk:6.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "VbApp.dll"]

Then running the following commands from the console will output "Hello World"

docker build -t vbapp-image -f Dockerfile .
docker create --name vbapp vbapp-image
docker start vbapp -a 
Related