docker/build-push-action@v7
Build and push Docker images with Buildx
At a glance
- Latest major
v7- Repository
- docker/build-push-action
- Inputs
- 33 (0 required)
- Outputs
- 3
- 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/build-push-action@v7Inputs
| Name | Required | Default | Description |
|---|---|---|---|
add-hosts | No | none | List of a customs host-to-IP mapping (e.g., docker:10.180.0.1) |
allow | No | none | List of extra privileged entitlement (e.g., network.host,security.insecure) |
annotations | No | none | List of annotation to set to the image |
attests | No | none | List of attestation parameters (e.g., type=sbom,generator=image) |
build-args | No | none | List of build-time variables |
build-contexts | No | none | List of additional build contexts (e.g., name=path) |
builder | No | none | Builder instance |
cache-from | No | none | List of external cache sources for buildx (e.g., user/app:cache, type=local,src=path/to/dir) |
cache-to | No | none | List of cache export destinations for buildx (e.g., user/app:cache, type=local,dest=path/to/dir) |
call | No | none | Set method for evaluating build (e.g., check) |
cgroup-parent | No | none | Optional parent cgroup for the container used in the build |
context | No | none | Build's context is the set of files located in the specified PATH or URL |
file | No | none | Path to the Dockerfile |
labels | No | none | List of metadata for an image |
load | No | false | Load is a shorthand for --output=type=docker |
network | No | none | Set the networking mode for the RUN instructions during build |
no-cache | No | false | Do not use cache when building the image |
no-cache-filters | No | none | Do not cache specified stages |
outputs | No | none | List of output destinations (format: type=local,dest=path) |
platforms | No | none | List of target platforms for build |
provenance | No | none | Generate provenance attestation for the build (shorthand for --attest=type=provenance) |
pull | No | false | Always attempt to pull all referenced images |
push | No | false | Push is a shorthand for --output=type=registry |
sbom | No | none | Generate SBOM attestation for the build (shorthand for --attest=type=sbom) |
secrets | No | none | List of secrets to expose to the build (e.g., key=string, GIT_AUTH_TOKEN=mytoken) |
secret-envs | No | none | List of secret env vars to expose to the build (e.g., key=envname, MY_SECRET=MY_ENV_VAR) |
secret-files | No | none | List of secret files to expose to the build (e.g., key=filename, MY_SECRET=./secret.txt) |
shm-size | No | none | Size of /dev/shm (e.g., 2g) |
ssh | No | none | List of SSH agent socket or keys to expose to the build |
tags | No | none | List of tags |
target | No | none | Sets the target stage to build |
ulimit | No | none | Ulimit options (e.g., nofile=1024:1024) |
github-token | No | ${{ github.token }} | GitHub Token used to authenticate against a repository for Git context |
Outputs
| Name | Description |
|---|---|
imageid | Image ID |
digest | Image digest |
metadata | Build result metadata |
Read an output with ${{ steps.<step-id>.outputs.<name> }}; the step needs an id.
Examples
Build an image without pushing
Check that the Dockerfile builds on every pull request.
name: Example
on:
push:
branches: [main]
permissions:
contents: read
jobs:
example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Build and push Docker images
uses: docker/build-push-action@v7
with:
context: .
push: false
tags: "my-app:ci"Build and push to GHCR with layer cache
Reuse layers through the GitHub Actions cache backend.
name: Example
on:
push:
branches: [main]
permissions:
contents: read
packages: write
jobs:
example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker images
uses: docker/build-push-action@v7
with:
context: .
push: true
tags: "ghcr.io/${{ github.repository }}:latest"
cache-from: type=gha
cache-to: type=gha,mode=maxEach 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.