View Docker Container Logs

You can access the logs of your docker container by using the name or the id of the container and using the logs command. First find the container name or id with docker ps:

docker ps

CONTAINER ID        IMAGE           COMMAND                CREATED             STATUS              PORTS                           NAMES
78122b26a3b5        my-image        "python app.py"        17 hours ago        Up 17 hours         443/tcp, 0.0.0.0:1000->80/tcp   my-py-image
4e7568d83e94        my-image-2      "node dist/server.js   17 hours ago        Up 17 hours         0.0.0.0:3001->3000/tcp          my-node-image

Then you can show all logs since a particular date and time:

docker logs my-py-image --since 2019-04-05T12:00

You can get a straming output of the logs with the -f flag or –follow

docker logs my-py-image -f
docker logs my-py-image --follow

You can also combine the logs with a search, for example to find errors:

docker logs my-py-image | grep -i error

Read more about it here

Instagram Post