0

This should be a duplicate of this question: Docker look at the log of an exited container. But I cannot get anything in that question to work.

I'm running container with this command (copied from Azure WebApp startup script)

docker run -d -p 5785:80 --name web-bt_0_096c876f -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITE_SITE_NAME=web-bt -e WEBSITE_AUTH_ENABLED=False -e PORT=80 -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=web-bt.azurewebsites.net -e WEBSITE_INSTANCE_ID=5c991bc5716941ff1fb1eb90137ac2f13e1afffea161b14571d6ea1fb1356b3d -e HTTP_LOGGING_ENABLED=1 bt:latest -e environment='Production' -e ASPNETCORE_ENVIRONMENT='Production' 

This crashes for some reason (If I replace 'Production' with 'Development' in the two last parameters it works). This is what I'm trying to debug.

Now according to that other thread I should be able to do: docker logs -t web-bt_0_096c876f but this just returns immediately without printing anything at all.

Why is this empty. This returns nothing even if I replace the startup script with -e environment='Development' -e ASPNETCORE_ENVIRONMENT='Development' which actually works. I can browse to the web-app. But still no logs at all.

So how do I view the container logs/console output?

JensB
  • 6,663
  • 2
  • 55
  • 94
  • Maybe the production environment is not configured to log to stdout? – Krumelur Apr 20 '20 at 20:56
  • My docker knowledge is limited, but if I run the app outside of Docker (its a .net core app) everything I could possibly want to know is logged to the console window. Do I need to do anything in the dockerfile to capture the log? Also Im using serilog, and I do log to the console for all environments. – JensB Apr 20 '20 at 20:57
  • Are you sure that container produces log at all? Have you tried to run app itself? – Yasen Apr 20 '20 at 21:14
  • I'm not sure of anything regarding Docker. But If I run the asp.net core app without Docker directly from Visual studio 2019 in Release mode then I get logs written to the console. – JensB Apr 20 '20 at 21:18
  • If you remove the `docker run -d` option, it will run in the foreground and print its logs directly to the local console. If it also crashes promptly, then you'll get a shell prompt back right after it exits. – David Maze Apr 20 '20 at 22:11

0 Answers0