Skip to content

Cross-platform docker images built with GitHub actions

I run a number of docker containers on a couple of Raspberry Pi 4's. These are running arm64 version of raspbian. To build the docker images for these servers I found it was easiest to use GitHub Actions and get that do do the hard work.

This is an base level example workflow that I use.

Assuming the root of your GitHub repository has a working Dockerfile. Create a file in .github/workflows, say 'build.yaml' with the following contents.


name: Build Image Cross Platform

    branches: [ master ]
    branches: [ master ]


    runs-on: ubuntu-latest

    - uses: actions/[email protected]

    # this is a simple way of using date and time to do versioning.
    - name: Modify scripts and get version
      id: version
      run: |
        output=$(date -u '+%Y%m%d%H%M%S')
        echo ::set-output name=date_version::$output

    - name: Set up QEMU
      uses: docker/[email protected]

      name: Login to GitHub Container Registry
      uses: docker/[email protected] 
        username: ${{ github.repository_owner }}
        password: ${{ secrets.GITHUB_TOKEN }}
      name: Set up Docker Buildx
      id: buildx
      uses: docker/[email protected]
      name: Available platforms
      run: echo ${{ steps.buildx.outputs.platforms }}

    # here you can do additional steps

      name: Build and push
      uses: docker/[email protected]
        context: ./
        file: ./Dockerfile
        platforms: linux/arm64, linux/amd64
        push: true
        tags: |

Under platforms you can list any compatible docker buildx platforms you need. The platforms will be printed in the action log when it is run. Currently these are:

  • linux/amd64
  • linux/arm64
  • linux/riscv64
  • linux/ppc64le
  • linux/s390x
  • linux/386
  • linux/mips64le
  • linux/mips64
  • linux/arm/v7
  • linux/arm/v6