docker - 如何将 Docker 与 GitHub Actions 结合使用?

标签 docker github-actions

当我创建 GitHub 操作工作流文件时,示例 YAML 文件包含 runs-on: ubuntu-latest . According to the docs ,我只能在几个版本的 Ubuntu、Windows Server 和 macOS X 之间进行选择。

我认为 GitHub Actions 在 Docker 中运行。如何选择我的 Docker 镜像?

最佳答案

GitHub 操作提供了一个虚拟机——正如你所指出的,无论是 Ubuntu、Windows 还是 macOS——并在其中运行你的工作流程。然后,您可以使用该虚拟机在容器内运行工作流。

使用 the container specifier在容器内运行一个步骤。请务必指定 runs-on作为容器的适当主机环境(ubuntu-latest 用于 Linux 容器,windows-latest 用于 Windows 容器)。例如:

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

关于docker - 如何将 Docker 与 GitHub Actions 结合使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57549439/

相关文章:

docker - DevOps 简单设置

docker - flask应用程序无法访问容器/主机外部的sqlite数据库

mysql - 无法将 CSV 加载到 MySQL -(OS errno 13 - 权限被拒绝)

linux - 如何在不同的容器中运行相同的命令?

github-actions - 尝试发布我的 Github 页面时出现构建错误

powershell - 防止在启动Docker容器时Gitlab将-NoProfile添加到PowerShell

docker - 在 github ci 中进入 docker 容器之前如何在主机中运行命令

git - 如何设置 GoReleaser 将 brew tap 推送到不同的存储库

docker - Github Actions中的Vuejs到Docker容器

Github Action scp Action 失败