我正在通过this教程并尝试在EC2容器服务上安装一个简单的ASP.Net核心应用程序。我要到最后但不能让我的容器开始。当我输入时:
Project RedisGeo.ServiceModel (.NETStandard,Version=v1.6) was previously compiled. Skipping compilation.
Project RedisGeo.ServiceInterface (.NETStandard,Version=v1.6) was previously compiled. Skipping compilation.
Project RedisGeo (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
fail: ServiceStack.Redis.RedisNativeClient[0]
Could not connect to redis Instance at localhost:6379
fail: ServiceStack.Redis.RedisNativeClient[0]
Could not connect to redis Instance at localhost:6379
fail: ServiceStack.Redis.RedisNativeClient[0]
localhost:6379
Unhandled Exception: ServiceStack.Redis.RedisException: localhost:6379 ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: Connection refused 127.0.0.1:6379
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at System.Net.Sockets.Socket.Connect(IPAddress address, Int32 port)
at ServiceStack.Redis.RedisNativeClient.Connect() in /opt/lib/teamcity-agent/work/8dcfdcec54d0f21a/src/ServiceStack.Redis/RedisNativeClient_Utils.cs:line 212
at ServiceStack.Redis.RedisNativeClient.AssertConnectedSocket() in /opt/lib/teamcity-agent/work/8dcfdcec54d0f21a/src/ServiceStack.Redis/RedisNativeClient_Utils.cs:line 257
--- End of inner exception stack trace ---
at ServiceStack.Redis.RedisNativeClient.AssertConnectedSocket() in /opt/lib/teamcity-agent/work/8dcfdcec54d0f21a/src/ServiceStack.Redis/RedisNativeClient_Utils.cs:line 273
at ServiceStack.Redis.RedisNativeClient.AssertServerVersionNumber() in /opt/lib/teamcity-agent/work/8dcfdcec54d0f21a/src/ServiceStack.Redis/RedisNativeClient_Utils.cs:line 47
at ServiceStack.Redis.RedisClient.GetServerRole() in /opt/lib/teamcity-agent/work/8dcfdcec54d0f21a/src/ServiceStack.Redis/RedisClient.cs:line 1092
at ServiceStack.Redis.RedisResolver.CreateRedisClient(RedisEndpoint config, Boolean master) in /opt/lib/teamcity-agent/work/8dcfdcec54d0f21a/src/ServiceStack.Redis/RedisResolver.cs:line 84
at ServiceStack.Redis.RedisManagerPool.GetClient() in /opt/lib/teamcity-agent/work/8dcfdcec54d0f21a/src/ServiceStack.Redis/RedisManagerPool.cs:line 194
at RedisGeo.AppHost.ImportCountry(IRedisClientsManager redisManager, String countryCode) in /app/RedisGeo/AppHost.cs:line 35
at RedisGeo.AppHost.Configure(Container container) in /app/RedisGeo/AppHost.cs:line 30
at ServiceStack.ServiceStackHost.Init() in /opt/lib/teamcity-agent/work/d09206570215629/src/ServiceStack/ServiceStackHost.cs:line 189
at ServiceStack.NetCoreAppHostExtensions.UseServiceStack(IApplicationBuilder app, AppHostBase appHost) in /opt/lib/teamcity-agent/work/d09206570215629/src/ServiceStack/AppHostBase.NetCore.cs:line 178
at RedisGeo.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in /app/RedisGeo/Startup.cs:line 27
--- 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.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at RedisGeo.Program.Main(String[] args) in /app/RedisGeo/Program.cs:line 14
手动运行容器我收到以下错误:
FROM microsoft/dotnet:1.1-sdk-projectjson
COPY src /app
WORKDIR /app
RUN ["dotnet", "restore"]
WORKDIR /app/RedisGeo
RUN ["dotnet", "build"]
EXPOSE 5000/tcp
ENV ASPNETCORE_URLS https://*:5000
ENTRYPOINT ["dotnet", "run", "--server.urls", "http://*:5000"]
任何帮助将不胜感激,我是AWS的新手,所以如果我能提供更多信息,请告诉我。
这是我的泊坞文件:
docker ps --format "{{.ID}}: {{.Status}} {{.Command}} {{.Ports}}"
当我运行以下命令8285b5479401: Up 22 hours "/agent"
ba110a5f14ef: Up 46 hours "/app/docker-entrypoi" 0.0.0.0:80->80/tcp, 443/tcp
时,我得到当前正在运行的docker容器的以下输出
getScroll
ecsdemo-redisgeo任务容器定义
答案 0 :(得分:0)
Connection refused 127.0.0.1:6379
此错误表示127.0.0.1:6379
上没有可用的Redis服务器实例。
确保您的task-definition.json与ECS task-definition.json相同,其中包含${IMAGE_NAME}-redis
容器定义,该定义将告知ECS还在您的App上部署redis-server Docker实例。您可以在redis-geo/scripts找到用于部署redis-geo App的脚本。
可以从REDIS_HOST Environment Variable访问redis服务器实例的主机名,use in your App存在,例如:
container.Register<IRedisClientsManager>(c =>
new RedisManagerPool(AppSettings.Get("REDIS_HOST", defaultValue:"localhost")));
答案 1 :(得分:0)
当我尝试开发教程时遇到了同样的问题,经过几次试验和失败后,最终我通过从task-definition.json文件中删除以下条目来设法让它工作。
{
"name": "SERVICESTACK_LICENSE",
"value": "${SERVICESTACK_LICENSE}"
},
失败的原因是因为我在travis中没有任何条目,我猜它无法读取此后的REDIS_HOST。