docker/metadata-action@v6

GitHub Action to extract metadata (tags, labels) for Docker

At a glance

Latest major
v6
Repository
docker/metadata-action
Inputs
11 (2 required)
Outputs
10
Runs using
node24
License
Apache-2.0
Last checked

Inputs and outputs come straight from the action's official action.yml. See our editorial standards.

Usage

- uses: docker/metadata-action@v6

Inputs

NameRequiredDefaultDescription
contextYesworkflowWhere to get context data. Allowed options are "workflow" (default), "git".
imagesNononeList of Docker images to use as base name for tags
tagsNononeList of tags as key-value pair attributes
flavorNononeFlavors to apply
labelsNononeList of custom labels
annotationsNononeList of custom annotations
sep-tagsNononeSeparator to use for tags output (default \n)
sep-labelsNononeSeparator to use for labels output (default \n)
sep-annotationsNononeSeparator to use for annotations output (default \n)
bake-targetNononeBake target name (default docker-metadata-action)
github-tokenYes${{ github.token }}GitHub Token as provided by secrets

Outputs

NameDescription
versionGenerated Docker image version
tagsGenerated Docker tags
tag-namesGenerated Docker tag names without image base name
labelsGenerated Docker labels
annotationsGenerated annotations
jsonJSON output of tags and labels
bake-file-tagsBake definition file with tags
bake-file-labelsBake definition file with labels
bake-file-annotationsBake definition file with annotations
bake-fileBake definition file with tags and labels

Read an output with ${{ steps.<step-id>.outputs.<name> }}; the step needs an id.

Examples

Generate tags and labels

Derive image tags from branches, tags and the commit SHA instead of hand-writing them.

name: Example
on:
  push:
    branches: [main]

permissions:
  contents: read

jobs:
  example:
    runs-on: ubuntu-latest
    steps:
      - name: Docker Metadata action
        id: meta
        uses: docker/metadata-action@v6
        with:
          images: ghcr.io/${{ github.repository }}
          tags: |
            type=ref,event=branch
            type=sha
      - name: Use the output
        run: echo "tags = ${{ steps.meta.outputs.tags }}"

Each example passed actionlint (syntax, expressions and the inputs it knows for this action). They were not run in a live repository, so replace placeholder values such as names, ARNs and paths with your own.

Something out of date or wrong? Report it on our Contact page. This page is rebuilt from the action's repository roughly once a week.