Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Peter Nielsen 151 posts 208 karma points
    1 day ago
    Peter Nielsen
    0

    Hi

    I've been struggling with setting up umbraco 10 with Docker, so I was hoping you could push me in the right direction.

    I have created a brand new Umbraco with the newest dotnet sdk installed on mac.

    $ dotnet new umbraco --name Umbraco10Test
    

    And then I can publish it by doing

    $ dotnet publish Umbraco10Test.csproj --configuration Release --no-restore --output ./app
    $ cd app
    $ dotnet Umbraco10Test.dll
    

    And then I can go to http://localhost:5000 and install my Umbraco. So far so good. And if in my appsettings.json file add:

     "Kestrel": {
       "Endpoints": {
         "properties": {
           "Url": "http://localhost:4000"  
         }
       } 
     }
    

    I am able to change to port listening to 4000 instead of 5000.

    Cool. Now I want to put it into Docker. I have created this Dockerfile.

    ########################
    ### build
    ########################
    FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
    
    ARG PROJECT
    
    WORKDIR /src
    
    ENV PROJECT=${PROJECT}
    
    COPY . .
    
    RUN dotnet restore "${PROJECT}.csproj"
    
    RUN dotnet publish "${PROJECT}.csproj" --configuration Release --no-restore --output /app
    
    ########################
    ### final
    ########################
    FROM mcr.microsoft.com/dotnet/aspnet:6.0 
    
    ARG PROJECT
    
    WORKDIR /app
    
    ENV ASPNETCORE_URLS "http://*:4000"
    
    ENV DLL="${PROJECT}.dll"
    
    COPY --from=build /app .
    
    RUN echo "#!/bin/sh\ndotnet ${DLL}" > ./entrypoint.sh
    RUN chmod +x ./entrypoint.sh
    
    EXPOSE 4000
    
    ENTRYPOINT ["./entrypoint.sh"]
    

    And then I build and run the docker with this:

    $ docker build --no-cache --progress=plain -t umbraco10test_docker --build-arg PROJECT=Umbraco10Test .
    $ docker run --rm -d -p 4000:4000 --name umbraco10 umbraco10test_docker
    

    If i try and go to http://localhost:4000 then I get a ERR_EMPTY_RESPONSE error page, and if I try to curl this I get a curl: (52) Empty reply from server

    If I docker exec -it umbraco10 /bin/bash into the running container and try execute the same entrypoint.sh file created by the Dockerfile, I get this error:

    Unhandled exception. System.IO.IOException: Failed to bind to address http://127.0.0.1:4000: address already in use.
     ---> Microsoft.AspNetCore.Connections.AddressInUseException: Address already in use
     ---> System.Net.Sockets.SocketException (98): Address already in use
       at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
    

    So it seems to be runnning. I have a suspicion that it has to do with https and ssl, and another port or maybe 0.0.0.0 vs 127.0.0.1, but can figure it out. Hope you can help me :)

    Cheers

    Peter

  • girish 5 posts 76 karma points
    1 day ago
    girish
    0

    Hi Peter Nielsen,

    Just kill the process/port and try again.

    Otherwise Go to Project Properties > Deubg tab > Web Server Settings > App URL and add some different ports.

  • Peter Nielsen 151 posts 208 karma points
    1 day ago
    Peter Nielsen
    0

    Hi Girish

    Ehm. Where? Inside the Docker container? :) Im not sure this is answering the right question, or is it just me? I was wondering what I did wrong, and why I could see the published version of my newly installed Umbraco inside af docker container. I can make it work in both debug and release mode on my machine :)

Please Sign in or register to post replies

Write your reply to:

Draft