mardi 5 mai 2015

Could not run asp.net mvc 6 on Docker

I followed the guidance at Visual Studio Code to create an ASP.NET MVC app. I can run it on my local (windows 8). But when I tried to publish it to Docker, and the problem happened.

My dockerfile like

FROM microsoft/aspnet:1.0.0-beta4

#install npm in docker image
RUN apt-get update && apt-get install -y curl
RUN curl -sL http://ift.tt/1oa11OK | bash -
RUN apt-get install -y nodejs

#install bower and grunt
RUN npm install -g bower
RUN npm install -g grunt-bower-cli
RUN npm install -g grunt
RUN npm install -g grunt-cli
RUN npm install -g grunt-bower-task

COPY project.json /app/

WORKDIR /app

RUN ["dnu", "restore"]

COPY . /app

CMD ["cd", "/app/"]
CMD ["npm", "install"]
CMD ["bower", "install"]

EXPOSE 5001

ENTRYPOINT ["dnx", "kestrel"]

Then I tried to build it

docker build -t thangchung/webdemo .

and

docker run -i -p 8080:5001 -t thangchung/webdemo

the problem when I run above code, it always threw exception

System.InvalidOperationException: Unable to resolve project 'kestrel' from /app/kestrel
  at Microsoft.Framework.Runtime.ApplicationHostContext..ctor (IServiceProvider serviceProvider, System.String projectDirectory, System.String packagesDirectory, System.String configuration, System.Runtime.Versioning.FrameworkName targetFramework, ICache cache, ICacheContextAccessor cacheContextAccessor, INamedCacheDependencyProvider namedCacheDependencyProvider, IAssemblyLoadContextFactory loadContextFactory, Boolean skipLockFileValidation) [0x00000] in <filename unknown>:0
  at Microsoft.Framework.Runtime.DefaultHost.Initialize (Microsoft.Framework.Runtime.DefaultHostOptions options, IServiceProvider hostServices) [0x00000] in <filename unknown>:0
  at Microsoft.Framework.Runtime.DefaultHost..ctor (Microsoft.Framework.Runtime.DefaultHostOptions options, IServiceProvider hostServices) [0x00000] in <filename unknown>:0
  at Microsoft.Framework.ApplicationHost.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder,
 System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0

Could anyone let me know why I could not run it on Docker?

Any suggestion is welcome. Thanks.

Aucun commentaire:

Enregistrer un commentaire