How to view logs in detached mode?

098

To view logs of a container running in detached mode, you can use the docker logs command followed by the container name or ID. Here’s the syntax:

docker logs CONTAINER_NAME_OR_ID

For example, if your container is named my_container, you would run:

docker logs my_container

You can also use additional flags with the docker logs command:

  • -f: Follow the log output (similar to tail -f).
  • --tail: Show only the last N lines of logs.

Example to follow logs:

docker logs -f my_container

This will allow you to see the logs generated by the container while it is running in detached mode.

0 Comments

no data
Be the first to share your comment!