If I am creating a docker image for one of my applications and publishing it in docker hub.

This image was downloaded by many users and ran that application in their containers and that generated application logs in a folder.

Now as a developer how can I see those application logs from my machine when that container is in remote computer for which I dont have access?

If it is a virtual machine, I can do ssh to that same machine and go to that folder anse see the logs for that particular application, so how it is possible with docker?

I am not talking about docker event logs, the logs generated by my python application with the logging module. Could you please help me on how to handle this case in dockers.

I don't have any experience with working on dockers.

2 Answers

Praveen Rewar On Best Solutions

docker exec can be used to run bash commands in a docker container. But in your case the containers are running in a remote machine and not in your local machine. So, in that case, you have 2 options. 1. ssh into the remote machine and then use docker exec command to check the logs. 2. Directly ssh to the docker container.

But, in both scenarios, you will need SSH access to the remote machines from the end users. I hope this helps.

David Maze On

If your application writes log files to the container filesystem, this is one of a couple of good uses for Docker bind mounts. If the operator (the person running the container; not you, the original software author) starts the container with

docker run -v $PWD/logs:/app/logs ... you/yourimage

then they will be able to read the log files directly on their host system.

As the original application developer, you have no access to these logs. This is the same as every other (non-SaaS) application: the end user installs software on their system and runs it, but it's on a system you can't log into, so you can't directly see things like log files. The techniques for dealing with this are the same as anything else: when a user files a bug report make sure they provide a sufficient reproduction, log files, and relevant configuration, and reproduce the issue yourself locally.