Docker从git存储库构建上下文,其中Dockerfile位于文件夹中 [英] Docker Compose build context from git repository with Dockerfile inside folder
问题描述
我想使用git存储库在docker compose项目中构建新映像,因为我需要更改一些ARG变量。
I would like to build a new image in my docker compose project using a git repository as I need to change some ARG vars.
我担心的是Dockerfile
My concern is that the Dockerfile is inside a folder of the git repository.
如何使用git仓库将文件夹指定为构建上下文?
How can be specified a folder as build context using a git repository?
存储库: https://github.com/wodby/drupal -php / blob / master / 7 / Dockerfile
version: "2"
services:
php:
build:
context: https://github.com/wodby/drupal-php.git
dockerfile: 7/Dockerfile
args:
- BASE_IMAGE_TAG=7.1
- WODBY_USER_ID=117
- WODBY_GROUP_ID=111
volumes:
- ./:/var/www/html
我尝试了dockerfile属性: FOLDER / + Dockerfile
I've tried the dockerfile property: "FOLDER/" + Dockerfile
但是仓库使用相对拍拍hs,但找不到依赖项:
But the repository uses relative paths, and it doesn't find dependencies:
---> 6cc2006e9102
Step 7/9 : COPY templates /etc/gotpl/
ERROR: Service 'phpe' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder740707850/templates: no such file or directory
推荐答案
应该是这样的: myrepo.git#:myfolder
It should be this way: myrepo.git#:myfolder
version: "2"
services:
php:
build:
context: https://github.com/wodby/drupal-php.git#:7
args:
- BASE_IMAGE_TAG=7.1
- WODBY_USER_ID=117
- WODBY_GROUP_ID=111
volumes:
- ./:/var/www/html
https://docs.docker.com/引擎/参考/命令行/构建/#git存储库
这篇关于Docker从git存储库构建上下文,其中Dockerfile位于文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!