aspnet / aspnet-docker

[Archived] ASP.NET Core Docker images for 1.x. Go to https://github.com/dotnet/dotnet-docker for 2.1 and up.
https://asp.net
719 stars 171 forks source link

Failed to run a container from a docker image of .Net Core 2.0 web application #322

Closed danielman111 closed 6 years ago

danielman111 commented 6 years ago

If you are having an issue with microsoft/aspnet, please open an issue on https://github.com/Microsoft/aspnet-docker. This repository is for microsoft/aspnetcore and microsoft/aspnetcore-build.

Steps to reproduce the issue

(e.g. copy your Dockerfile or docker-compose.yml file here)

FROM microsoft/aspnetcore:2.0
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "LoggerService.dll"]

Expected behavior

Running a created docker image properly

Actual behavior

Getting the following error

Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
  http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

Additional information (e.g. issue happens only occasionally)

I'm trying to run an .NET Core 2.0 web app on a Docker container. My project name is LoggerService. I am publishing the project to

LoggerService\obj\Docker\publish\

And than running the command

docker-compose build

The LoggerService image is created, but when trying to run it I am getting the following message:

Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
  http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

Output of dotnet --info

.NET Command Line Tools (2.0.0)

Product Information:
 Version:            2.0.0
 Commit SHA-1 hash:  cdcd1928c9

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15063
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.0.0\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

Output of docker info

Containers: 73
 Running: 0
 Paused: 0
 Stopped: 73
Images: 33
Server Version: 17.09.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 3f2f8b84a77f73d38244dd690525642a72156c64
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.49-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: moby
ID: 2P6K:OFSA:PP4L:IXHT:TBLL:PV6K:Y4GI:5V5M:OIPP:2OEF:AX3Q:DV5T
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 24
 Goroutines: 58
 System Time: 2017-11-01T08:43:19.5230459Z
 EventsListeners: 0
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
natemcmaster commented 6 years ago

Can you also share your docker-compose.yml file? From what I can tell, this error message is coming from another place in your build setup, not the microsoft/aspnetcore image itself.

muratg commented 6 years ago

No repro

gnupot commented 6 years ago

I got the same error. In my case, I fixed it just change assembly name in entry point, e.g: ENTRYPOINT ["dotnet", "UserServer.dll"] instead ENTRYPOINT ["dotnet", "userserver.dll"]

muratg commented 6 years ago

@gnupot Nice! Were you able to identify the reason for the casing difference?

gnupot commented 6 years ago

@muratg for my Dockerfile I got a template from docker's example https://docs.docker.com/engine/examples/dotnetcore/ where entry point was ENTRYPOINT ["dotnet", "aspnetapp.dll"] I just replaced example dll name to my "userserver.dll"

but my Project file contains a tag ``

UserServer

`` so I get assembly UserServer.dll after compilation

and as I think docker doesn't find "userserver.dll" when I run container

natemcmaster commented 6 years ago

Linux file systems are case sensitive :)

muratg commented 6 years ago

@gnupot Got it. I also just verified that the created assembly name matches the casing of the csproj name (if there's no attribute specifying the assembly name).

gnupot commented 6 years ago

@natemcmaster Yep, but I think users can be confused by the error message

Did you mean to run dotnet SDK commands? Please install dotnet SDK from: http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

natemcmaster commented 6 years ago

@gnupot Agreed. Didn't realize how unhelpful that error was when the SDK isn't installed. I've opened https://github.com/dotnet/core-setup/issues/3490 to improve this.

NerkiTrzy commented 6 years ago

try change first line of dockerfile into: FROM microsoft/aspnetcore-build:2.0 AS build-env it resolved my problem with:

"Did you mean to run dotnet SDK commands? Please install dotnet SDK from: http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409"

Dgreyvenstein commented 6 years ago

I fixed it by changing the entry point to my dll name. I followed a tutorial, but had a different project name.

pimbrouwers commented 6 years ago

For me the casing of the run command had nothing to do with it. But rather referencing the wrong image. For example:

FROM microsoft/aspnetcore:2.0

When it should've been:

FROM microsoft/aspnetcore-build:2.0

I presume this is because microsoft/aspnetcore:2.0 is a runtime-only image.

SibeeshVenu commented 6 years ago

@pimbrouwers Thanks for putting some light over here, that was the exact issue I was facing. Changing to FROM microsoft/aspnetcore-build:2.0 from FROM microsoft/aspnetcore:2.0 did the trick for me as well.

anatalin commented 6 years ago

Hey, guys, just had the same error message: "Did you mean to run dotnet SDK commands?" The project was located on D: drive. Docker has access to both C: and D: drives. Solved the problem by moving project from D: to C:

Hope it will help someone.

PS-StuartZahn commented 6 years ago

Would appreciate a better error message if trying to pass in an entrypoint file for dotnet to run.

MrRogov commented 5 years ago

I had the same issue on VS 17 v 15.9.5. The project was on drive D: . I fixed it by replacing the project on drive C: