Skip to content
align-left

GitHub Action

Collect Docker Logs

v2.2.2 Latest version

Collect Docker Logs

align-left

Collect Docker Logs

Collect logs from all docker containers

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Collect Docker Logs

uses: jwalton/[email protected]

Learn more about this action in jwalton/gh-docker-logs

Choose a version

Collect Docker Logs

semantic-release

This is a GitHub Action which will collect logs from all running docker containers. Logs can either be dumped to stdout, or can be written to a folder (where you can tar them up and upload them as an artifact).

Inputs

  • dest - Destination folder to write to. If not provided, logs will be written to stdout. If provided, the folder will be created if it doesn't exist, and files will be written based on container names (e.g. 'redis.log').

  • images - A comma delimited list of image names. If provided, only output from containers with these images will be shown. Containers will match if the image matches exactly (e.g. "mongo:3.4.22") or if the image name matches without a tag (e.g. "mongo" will match "mongo:3.4.22").

  • tail - Max number of lines to show from each container. Defaults to "all".

  • shell - Shell to execute commands. Defaults to "/bin/sh".

Usage

Dump all logs on a failure

- name: Dump docker logs on failure
  if: failure()
  uses: jwalton/gh-docker-logs@v2

Dump redis and mongodb logs

- name: Dump redis logs
  uses: jwalton/gh-docker-logs@v2
  with:
    images: 'redis,mongo'
    # Only show last 100 lines of each
    tail: '100'

Upload tarball as artifact

- name: Collect docker logs on failure
  if: failure()
  uses: jwalton/gh-docker-logs@v2
  with:
    dest: './logs'
- name: Tar logs
  if: failure()
  run: tar cvzf ./logs.tgz ./logs
- name: Upload logs to GitHub
  if: failure()
  uses: actions/upload-artifact@master
  with:
    name: logs.tgz
    path: ./logs.tgz

Dump all logs on a failure using different shell

- name: Dump docker logs on failure using different shell
  if: failure()
  uses: jwalton/gh-docker-logs@v2
  with:
    shell: '/bin/sh'