简体   繁体   中英

Python logging in Docker. How to access log file formed inside the Docker container

I have made a Flask API for a spacy ner code and deployed it on Docker. In the code I have used python's logging to return the outputs to a file, info.log.

The question is, how to access the log file in the container after running it.

Since I had to look for a long time, I picked up bits of answers from different places and am compiling it here for anyone who is stuck.

After running the container, go to the terminal and post the following commands. (I used pycharm and the terminal started inside the directory where my code and dockerfile were stored)

docker ps

(this shows the containers running currently)

docker exec -it 'container-name' bash

(now you have entered the container)

ls -lsa

(this will show all the files in the container, including the log file)

cat info.log

Now, you can see the log file contents on the terminal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM