Service Logs

  • Same as docker container logs, but aggregates all service tasks

  • Can return all tasks at once, or just one task's logs

  • Great for real time cli troubleshooting

  • Has options for follow/tail, and other common log options

  • Not for log storage, or searching, or feeding into other systems

  • Doesn't work if you use --log-driver for sending logs off server

  • Therefore: use for small Swarms and testing

Examples

  • Return all logs for a service

    • docker service logs <servicename/id>

  • Return all logs for a single task

    • docker service logs <taskid>

  • Return unformatted logs with no trunking

    • docker service logs --raw --no-trunc <servicename/id>

  • Only return last 50 log entries and all future logs

    • docker service logs --tail 50 --follow <servicename/id>

  • Search in logs (both stdout and stderr)

    • docker service logs <servicename> 2>&1 | grep <search string>

    • docker service logs <servicename> 2>&1 | findstr <search string>

Last updated

Was this helpful?