docker - 如何在我的 github 操作中指定 dockerfile 位置?
问题描述
我正在向我的 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.
任何帮助,将不胜感激!
解决方案
这一行有一个问题:
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)
推荐阅读
- java - 从资源文件中获取 String 和 Drawable 到 Fragment View Model 类
- angular - ngFor 迭代 n+1 次以获得至少 1 个值
- python - 在 Python 中将序列拆分为单个步骤的最优雅方法
- r - 在 R 中的地图上显示时间序列预测的预测区间(空间建模)
- c# - Firebase RealTime DB - 查询返回旧的 DataSnapshot - 而不是新键,除非重新启动应用程序
- c# - Specflow 允许可为空的表参数
- python - 为什么我的 Flask API 端点出现 CORS 错误,而其他类似编程的端点却没有?
- nginx - 从 Codepipeline 更新文件后 AWS EC2 站点未更新
- python - 将熊猫数据框插入influxdb的问题
- javascript - flex 框的样式问题,文本走得太远