【问题标题】:How do I specify the dockerfile location in my github action?如何在我的 github 操作中指定 dockerfile 位置?
【发布时间】:2020-05-18 16:11:13
【问题描述】:

我正在向我的 asp.net 核心应用程序添加一个 dockerfile,它位于一个子目录中。我正在尝试创建一个 github 操作来运行 dockerfile,但该操作很难找到它。 我的文件夹结构是:

api/
|--Data/
|--Service/
|--|--Dockerfile
|--Tests/
|--MyProject.sln
frontend/

我的 action.yml 是:


name: Docker Image CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:

  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Build the Docker image
      run: docker build ./api/Service/ --file Dockerfile --tag my-image-name:$(date +%s)

当操作运行时,我在 docker build 上收到以下错误。

Run docker build ./api/Service/ --file Dockerfile --tag my-image-name:$(date +%s)
  docker build ./api/Service/ --file Dockerfile --tag my-image-name:$(date +%s)
  shell: /bin/bash -e {0}
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/runner/work/MyProject-actions/MyProject-actions/Dockerfile: no such file or directory
##[error]Process completed with exit code 1.

任何帮助将不胜感激!

【问题讨论】:

    标签: docker asp.net-core github-actions


    【解决方案1】:

    这行有问题:

    run: docker build ./api/Service/ --file Dockerfile --tag my-image-name:$(date +%s)
    

    --file 标志的用法错误。正确的做法是:

    run: docker build --file ./api/Service/Dockerfile --tag my-image-name:$(date +%s)
    

    【讨论】:

      猜你喜欢
      • 2022-11-03
      • 1970-01-01
      • 2021-02-24
      • 2021-10-02
      • 2020-11-04
      • 2021-07-12
      • 2021-08-31
      • 1970-01-01
      • 2021-03-01
      相关资源
      最近更新 更多