Reputation: 15891
I can succesully install and run an ASP.Net MVC application https://github.com/aspnet/Home/tree/dev/samples/1.0.0-beta4/HelloMvc on docker using:
Dockerfile
FROM microsoft/aspnet
COPY . /app
WORKDIR /app
RUN ["dnu", "restore"]
EXPOSE 5004
ENTRYPOINT ["dnx", "." "kestrel"]
Build
docker build -t myapp .
Run
docker run -t -d -p 80:5004 myapp
The Buildstep takes 2minutes, thats why I don't want to to run all the steps when I changed some files during development. What workflow would I use when developing for a runtime that is hosted in docker? Or is docker not the right environment for development?
EDIT I copied all files of the application including the dockerfile to "/dev_app" changed to that directory and run
$ docker run -v /dev_app:/app -d -p 80:5004 myapp
The output is the id of the container
docker ps
Does not show any entries. Is there still something missing?
EDIT 2
executing
docker log [myid]
returns
System.InvalidOperationException: Unable to resolve project 'app' from /app
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
Upvotes: 1
Views: 226
Reputation: 46480
During development, put the code in a directory on host and mount that into the container, over the top of the existing code. For example, if you put a copy of the code in dev_app
in your current directory:
$ docker run -v $(pwd)/dev_app:/app -d -p 80:5004 myapp
Any changes to the code in the dev_app
directory will be reflected immediately in the container. When you've finished making changes, you can rebuild the container with the new version of the code for distribution.
Upvotes: 1