How to install docker on GitHub Actions
Asked Answered
D

1

11

What is the official / recommended way to install Docker on GitHub Actions?

In particular I need to run a custom script on GitHub Actions that, among other tasks, calls docker build and docker push.

I don't want pre-made actions that build/push, I want to have access to the docker command.

What should I do?

The only official action that I can find uses Docker Buildx and not the normal docker: https://github.com/marketplace/actions/build-and-push-docker-images

Beside that I can find this action (https://github.com/marketplace/actions/setup-docker) but I don't know if I can trust that source, since it's not official.

Any recommendations? How do you install the docker command on GitHub Actions?

Discomfort answered 30/4, 2022 at 10:22 Comment(1)
It seems Docker is already installed on the Github Runners (you can see it here for ubuntu-latest). I performed a test just running docker --version without any setup and it returned Docker version 20.10.14+azure-1, build a224086349269551becacce16e5842ceeb2a98d6 as you can see in this workflow runSun
S
3

Docker is already available in the default ubuntu images.

You can find all the installed software in actions/runner-images.

It looks like Windows and Mac images do not have the Docker client installed: Search results.

This is a valid CI that I use in my workflow:

name: Check that image builds
on:
  pull_request:

jobs:
  test-image:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Check that the image builds
        run: docker build . --file Dockerfile
Stipend answered 8/5 at 14:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.