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

Container exits with error code (134) - Following tutorial exactly. #233

Closed DanJ210 closed 7 years ago

DanJ210 commented 7 years ago

Lol I am ripping my hair out trying to figure out what I'm doing wrong.

Steps to reproduce the issue

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

  1. Follow tutorial
  2. dotnet publish -o:./published
  3. docker build -t myapp .
  4. docker run -d -p 8000:80 myapp

Expected behavior

Expecting to be able to run the container with a published ASP.NET Core app.

Actual behavior

Container exits after seconds with error code (134)

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

I've tried many different combinations and also suggestion in the comments of the tutorial page below. I've also given my docker file with some of the different combinations I've tried but sticking to the tutorial. I've also taken a few screenshots of my filesystem to prove there's a published folder and the app .dll is in that published folder.

file:///c%3A/Users/djackson/testing/source/noc-pl-webapplication/NOC-PL-WebApplication/Dockerfile

docker-aspnetcore1

docker-aspnetcore2

docker-aspnetcore3

Output of dotnet --info

Error code 134

Output of docker info

Error code 134
natemcmaster commented 7 years ago

Try looking at the logs. docker run -d means "detached" mode. To see the dotnet app's output, run with docker run -it or inspect the logs manually with docker logs.

Also, did dotnet --info and docker info really both return Error code 134?

DanJ210 commented 7 years ago

@natemcmaster Thanks I will check the logs and see what's going on and report back here. I didn't realize I should have tried to get some logging.

And no dotnet --info and docker --info didn't return the Error code 134. I misunderstood what those areas were for exactly so I filled in only what I thought was supposed to go there, like info. My apologies on mistaking that.

DanJ210 commented 7 years ago

Ok so seeing the logs really helped and sorry to have bothered for something I should have learned on my own...

But what I think is happening, which should be common sense, is that the container won't talk to the SQL Server database like it does when I run it locally, via dotnet run connecting to the local SQL Server instance. So when the container is trying to run the application during container startup, it's failing because of not being to contact the database, that's my best guess at this moment.

Below I've posted all the logs for that container and that's what it's looking like, database issues causing the container to fail. So this issue could be closed and I'll be a little better at not having to bother you guys/girls for something like this in the future.

PS C:\Windows\system32> docker logs 7a [21:00:24 DBG] Compiling query model: '(from NocUser <generated>_1 in DbSet<NocUser> select <generated>_1) .Any()' [21:00:24 DBG] Optimized query model: '(from NocUser <generated>_1 in DbSet<NocUser> select <generated>_1) .Any()' [21:00:24 DBG] TRACKED: False (QueryContext queryContext) => IEnumerable<bool> _ToSequence( element: bool GetResult( valueBuffers: IEnumerable<ValueBuffer> _Query( queryContext: queryContext, shaperCommandContext: SelectExpression: SELECT CASE WHEN EXISTS ( SELECT 1 FROM [AspNetUsers] AS [a]) THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT) END , queryIndex: default(System.Nullable1[System.Int32]) ) ) )

[21:00:24 ERR] An exception occurred in the database while iterating the results of a query.

System.NotSupportedException: The keyword 'integrated security' is not supported on this platform. at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) at System.Data.SqlClient.SqlConnection..ctor(String connectionString) at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerConnection.CreateDbConnection() at Microsoft.EntityFrameworkCore.Internal.LazyRef1.get_Value() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open() at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.BufferlessMoveNext(Boolean buffer) at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](Func2 operation, Func2 verifySucceeded, TState state) at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.MoveNext() at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.GetResult[TResult](IEnumerable1 valueBuffers) at lambda_method(Closure , QueryContext ) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass20_0`1.b__0(QueryContext qc)

Unhandled Exception: System.AggregateException: One or more errors occurred. (The keyword 'integrated security' is not supported on this platform.) ---> System.No tSupportedException: The keyword 'integrated security' is not supported on this platform. at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) at System.Data.SqlClient.SqlConnection..ctor(String connectionString) at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerConnection.CreateDbConnection() at Microsoft.EntityFrameworkCore.Internal.LazyRef1.get_Value() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open() at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.BufferlessMoveNext(Boolean buffer) at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](Func2 operation, Func2 verifySucceeded, TState state) at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.MoveNext() at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.GetResult[TResult](IEnumerable1 valueBuffers) at lambda_method(Closure , QueryContext ) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>cDisplayClass20_01.<CompileQueryCore>b__0(QueryContext qc) at System.Linq.Queryable.Any[TSource](IQueryable1 source) at NOCPLWebApplication.Models.SeedData.ProductServerSeedData.d3.MoveNext() in C:\Users\djackson\testing\source\noc-pl-webapplication\NOC-PL-W ebApplication\Models\SeedData\ProductServerSeedData.cs:line 24 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at NOC_PL_WebApplication.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime appLifetime, Pr oductServerSeedData seeder) in C:\Users\djackson\testing\source\noc-pl-webapplication\NOC-PL-WebApplication\Startup.cs:line 113 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app) at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>cDisplayClass0_0.b0(IApplicationBuilder builder) at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at NOC_PL_WebApplication.Program.Main(String[] args) in C:\Users\djackson\testing\source\noc-pl-webapplication\NOC-PL-WebApplication\Program.cs:line 14 Aborted [17:16:26 DBG] Compiling query model: '(from NocUser _1 in DbSet select _1) .Any()' [17:16:26 DBG] Optimized query model: '(from NocUser _1 in DbSet select _1) .Any()' [17:16:26 DBG] TRACKED: False (QueryContext queryContext) => IEnumerable _ToSequence( element: bool GetResult( valueBuffers: IEnumerable _Query( queryContext: queryContext, shaperCommandContext: SelectExpression: SELECT CASE WHEN EXISTS ( SELECT 1 FROM [AspNetUsers] AS [a]) THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT) END , queryIndex: default(System.Nullable`1[System.Int32]) ) ) )

[17:16:26 ERR] An exception occurred in the database while iterating the results of a query.

System.NotSupportedException: The keyword 'integrated security' is not supported on this platform. at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) at System.Data.SqlClient.SqlConnection..ctor(String connectionString) at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerConnection.CreateDbConnection() at Microsoft.EntityFrameworkCore.Internal.LazyRef1.get_Value() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open() at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.BufferlessMoveNext(Boolean buffer) at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](Func2 operation, Func2 verifySucceeded, TState state) at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.MoveNext() at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.GetResult[TResult](IEnumerable1 valueBuffers) at lambda_method(Closure , QueryContext ) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass20_0`1.b__0(QueryContext qc)

Unhandled Exception: System.AggregateException: One or more errors occurred. (The keyword 'integrated security' is not supported on this platform.) ---> System.No tSupportedException: The keyword 'integrated security' is not supported on this platform. at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) at System.Data.SqlClient.SqlConnection..ctor(String connectionString) at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerConnection.CreateDbConnection() at Microsoft.EntityFrameworkCore.Internal.LazyRef1.get_Value() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open() at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.BufferlessMoveNext(Boolean buffer) at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](Func2 operation, Func2 verifySucceeded, TState state) at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable.Enumerator.MoveNext() at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.GetResult[TResult](IEnumerable1 valueBuffers) at lambda_method(Closure , QueryContext ) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>cDisplayClass20_01.<CompileQueryCore>b__0(QueryContext qc) at System.Linq.Queryable.Any[TSource](IQueryable1 source) at NOCPLWebApplication.Models.SeedData.ProductServerSeedData.d3.MoveNext() in C:\Users\djackson\testing\source\noc-pl-webapplication\NOC-PL-W ebApplication\Models\SeedData\ProductServerSeedData.cs:line 24 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at NOC_PL_WebApplication.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime appLifetime, Pr oductServerSeedData seeder) in C:\Users\djackson\testing\source\noc-pl-webapplication\NOC-PL-WebApplication\Startup.cs:line 113 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app) at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>cDisplayClass0_0.b0(IApplicationBuilder builder) at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication() at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at NOC_PL_WebApplication.Program.Main(String[] args) in C:\Users\djackson\testing\source\noc-pl-webapplication\NOC-PL-WebApplication\Program.cs:line 14 Aborted`

natemcmaster commented 7 years ago

@DanJ210 no worries, we're here to help. :)

The keyword 'integrated security' is not supported on this platform.

This is a common mistake when moving an app that runs on Windows into Linux-based Docker containers. Use User ID and Password instead in your connection string. Integrated Security is a Windows-only feature. If that doesn't help, checkout these samples: https://www.microsoft.com/en-us/sql-server/developer-get-started/

DanJ210 commented 7 years ago

@natemcmaster Thank you. I did do a few things to ensure I know what I'm doing and I now know how to create a service with a blank .Net Core application and an SQL Server Linux image under an isolated network created with a docker-compose.yml file. I've been able to add data and pull it to confirm it's working.

But when I try to do it with my application, as you've shown above, I'm getting the 'integrated security' issue. As of now my connection string is simple "Server=DJACKSON;Database=NocPlTable;User ID=sa;password=P@ssw0rd!;MultipleActiveResultSets=true;"

So I'm going to follow your link and see if I can find a solution with that but it looks like that may take quite a while. I could try to run with Windows containers but that's going to change everything! Lol.

Thanks for the help, I'll report back if I solve.

DanJ210 commented 7 years ago

Oh. The funny thing is that I can run the application and it works fine but when I use docker-compose up to turn on the same containers that are built from that same application, that's when I get the integrated security issue. Otherwise I don't. Only when docker-compose up

DanJ210 commented 7 years ago

@natemcmaster I made a very silly mistake. I had forgotten to republish the application... It was the first time I ever published a dotnet application but that was what happened.

The only thing I have to do now is run docker-compose up twice. The first time turns on both the sql server and my application image, but the application tries contacting sql server before it's actually up and running. So I run it once, then a second time and it all connects.

natemcmaster commented 7 years ago

Glad you were able to figure it out :)