Docker Compose build context from git repository with Dockerfile inside folder

北城余情 提交于 2019-12-22 17:24:06

问题


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.

My concern is that the Dockerfile is inside a folder of the git repository.

How can be specified a folder as build context using a git repository?

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

I've tried the dockerfile property: "FOLDER/" + Dockerfile

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

回答1:


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/engine/reference/commandline/build/#git-repositories



来源:https://stackoverflow.com/questions/50453931/docker-compose-build-context-from-git-repository-with-dockerfile-inside-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!