Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
play

GitHub Action

Docker Run Action

v2

Docker Run Action

play

Docker Run Action

Run a command in a new container

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Docker Run Action

uses: addnab/docker-run-action@v2

Learn more about this action in addnab/docker-run-action

Choose a version

Docker Run Action

Typical Use Case

- uses: addnab/docker-run-action@v2
  with:
    username: ${{ secrets.DOCKER_USERNAME }}
    password: ${{ secrets.DOCKER_PASSWORD }}
    registry: gcr.io
    image: private-image:latest
    options: -v ${{ github.workspace }}:/work -e ABC=123
    run: |
      echo "Running Script"
      /work/run-script

run a privately-owned image

- uses: addnab/docker-run-action@v2
  with:
    username: ${{ secrets.DOCKER_USERNAME }}
    password: ${{ secrets.DOCKER_PASSWORD }}
    registry: gcr.io
    image: test-image:latest
    run: echo "hello world"

run an image built by a previous step

- uses: docker/build-push-action@v1
  with:
    repository: test-image
    push: false
- uses: addnab/docker-run-action@v2
  with:
    image: test-image:latest
    run: echo "hello world"

use a specific shell (default: sh).

Note: The shell must be installed in the container

- uses: addnab/docker-run-action@v2
  with:
    image: docker:latest
    shell: bash
    run: |
      echo "first line"
      echo "second line"