How do I use Docker with GitHub Actions?

后端 未结 2 1268
面向向阳花
面向向阳花 2021-02-03 18:42

When I create a GitHub Actions workflow file, the example YAML file contains runs-on: ubuntu-latest. According to the docs, I only have the options between a couple

2条回答
  •  逝去的感伤
    2021-02-03 19:17

    GitHub actions provision a virtual machine - as you noted, either Ubuntu, Windows or macOS - and run your workflow inside of that. You can then use that virtual machine to run a workflow inside a container.

    Use the container specifier to run a step inside a container. Be sure to specify runs-on as the appropriate host environment for your container (ubuntu-latest for Linux containers, windows-latest for Windows containers). For example:

    jobs:
      vm:
        runs-on: ubuntu-latest
        steps:
          - run: |
              echo This job does not specify a container.
              echo It runs directly on the virtual machine.
            name: Run on VM
      container:
        runs-on: ubuntu-latest
        container: node:10.16-jessie
        steps:
          - run: |
              echo This job does specify a container.
              echo It runs in the container instead of the VM.
            name: Run in container
    

提交回复
热议问题