我一直在Docker容器中使用ASP.NET 5.0 beta 7運行一個網站,使用官方Docker鏡像 - https://github.com/aspnet/aspnet-docker - 這工作正常。Docker中的ASP.NET 5.0 beta 8未啓動
我最近將項目更新爲beta 8,並將Dockerfile更改爲使用Docker鏡像的beta 8版本。當我在Windows機器上本地運行它時,無論使用Visual Studio使用IIS Express啓動項目,還是使用Kestrel運行它,一切正常。
然而,然後我把它推到我的Dokku服務器,它似乎並沒有正常啓動。我沒有從容器輸出中得到任何錯誤,但是我有一個Dokku使用的CHECKS文件來確保Web服務器已經啓動,並且失敗(表明它沒有正確啓動,或者沒有按照它應該進行監聽) 。我嘗試刪除CHECKS,但無法連接到它 - 我從nginx收到一條錯誤的網關消息。
我不知道爲什麼會這樣,因爲當我推到Dokku,我得到如下回應:
...
remote: [1G-----> Attempt 5/5 Waiting for 10 seconds ...[K
remote: [1G CHECKS expected result:[K
remote: [1G http://localhost/ => "My Website"[K
remote: Could not start due to 1 failed checks.[K
remote: [1G ! [K
remote: [1Gcurl: (7) Failed to connect to 172.17.2.14 port 5000: Connection refused[K
remote: [1G ! Check attempt 5/5 failed.[K
remote: [1G=====> mywebsite container output:[K
remote: [1G info : [Microsoft.Framework.DependencyInjection.DataProtectionServices] User profile is available. Using '/root/.local/share/ASP.NET/DataProtection-Keys' as key repository; keys will not be encrypted at rest.[K
remote: [1G Hosting environment: Production[K
remote: [1G Now listening on: http://localhost:5000[K
remote: [1G Application started. Press Ctrl+C to shut down.[K
remote: [1G=====> end mywebsite container output[K`
...
這似乎很奇怪,因爲它看起來像它已經開始,但經過檢查有失敗。正如我所說,刪除支票意味着它成功部署,但後來我無法連接到它。
我Dockerfile是:
FROM microsoft/aspnet:1.0.0-beta8
# Install NPM
RUN apt-get update && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get install -y nodejs
# Install Gulp
RUN npm install -g gulp
COPY . /app
WORKDIR /app
RUN ["dnu", "restore"]
WORKDIR ./src/mywebsite
RUN ["npm", "install"]
RUN ["gulp", "min"]
EXPOSE 5000
ENTRYPOINT dnx kestrel
將我的Dockerfile的最後一行更改爲'ENTRYPOINT dnx kestrel --server.urls http://0.0.0.0:5000',謝謝! – user882807
嘿,太好了。很高興聽到它的幫助。 –
謝謝!我花了幾個小時和你的帖子來找出爲什麼我不能在我的容器中訪問Kestrel。 –