I can’t access the main Docker DotNet website

I have come to a standstill. I have a dotnet core 1.0.0 application that I am trying to start and run. It works fine with linux and from windows. Now I'm trying to get it to docker. I made this docker file:

FROM microsoft/dotnet:1.0.0-preview2-sdk

COPY . /app
WORKDIR /app/app
RUN ["dotnet", "restore"]

ENTRYPOINT ["dotnet", "run"] 

It simply copies the code to the application folder in the docker image and restores the dependencies, and then launches it. When I try to start it, it starts when everything works and prints the same as when starting Windows or Linux.

Docker console

The command to start the project:

docker run --name dotNetWeb -p 8080:8080 kiksen1987/dotnetcore

Link to code: https://github.com/kiksen1987/dotnetcore

Link to the Docker image: https://hub.docker.com/r/kiksen1987/dotnetcore/

, . , 99% .

:)

+4
2

-.

: http://dotnetliberty.com/index.php/2015/11/26/asp-net-5-on-aws-ec2-container-service-in-10-steps/

, dotnet, , :

, Ive - dnx, , 0.0.0.0 ( ). - , , Docker, 0.0.0.0.

.

:

var host = new WebHostBuilder()
            .UseKestrel()
            .UseStartup<Startup>()
            .UseUrls("http://0.0.0.0:5000")
            .Build();

:

var host = new WebHostBuilder()
            .UseKestrel()
            .UseStartup<Startup>()
            .UseUrls("http://localhost:5000")
            .Build();

, , Linux, Docker, . , :)

+9

ASP.NET Core Docker : https://hahoangv.wordpress.com/2016/05/23/asp-net-core-run-in-docker/

Dockerfile:

FROM microsoft/dotnet:1.0.0-preview2-sdk

# Set environment variables
ENV ASPNETCORE_URLS="http://*:5000"
ENV ASPNETCORE_ENVIRONMENT="Development"

# Copy files to app directory
COPY . /app

# Set working directory
WORKDIR /app

# Restore NuGet packages
RUN ["dotnet", "restore"]

# Open up port
EXPOSE 5000

# Run the app
ENTRYPOINT ["dotnet", "run"]

Program.cs:

public static void Main(string[] args)
        {
            // Get environment variables
            var config = new ConfigurationBuilder()
                .AddEnvironmentVariables(&quot;&quot;)
                .Build();
            // You need to add these lines for accessing outside of Docker
            var url = config["ASPNETCORE_URLS"] ?? "http://*:5000";
            var env = config["ASPNETCORE_ENVIRONMENT"] ?? "Development";

            var host = new WebHostBuilder()
                .UseKestrel()
                .UseUrls(url)
                .UseEnvironment(env)
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .Build();

            host.Run();
        }

!

0

All Articles