GitHub Actions - Push an image to Docker Hub using docker/build-push-action
by
Jeremy Canfield |
Updated: November 20 2025
| GitHub Actions articles
https://github.com/docker/build-push-action can be used to build and push an image to Docker Hub. For example, let's say you have the following workflow.
name: build and push image to Docker Hub
run-name: ${{ github.workflow }} run by ${{ github.actor }}
on:
workflow_dispatch:
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: johndoe/hello-world:0.0.0
By default, this workflow expects there to be a file named Dockerfile in the base directory of your GitHub repo. Let's say Dockerfile contains the following.
FROM alpine
CMD ["echo", "Hello World"]
In this example, the image will be pushed to the https://hub.docker.com/repositories/johndoe repo and tagged hello-world version 0.0.0. Assuming the workflow completes successfully, the image should be built and pushed to Docker Hub.
Did you find this article helpful?
If so, consider buying me a coffee over at 