Docker-compose与自定义目录中的git托管的映像

时间:2019-01-11 15:59:55

标签: git docker docker-compose

我的docker-compose YAML配置由

version: '3'
services:
  nginx:
    image: https://my-git-address.git#:dockers/nginx-dev
    ports:
      - 80:80
      - 443:443
    networks:
      dev-net:
        aliases:
          - app.dev.local
          - dev.local
    extra_hosts:
      - "foo.dev.local:127.0.0.1"

但编写失败并显示以下消息:

λ docker-compose up
Creating network "application_dev-net" with driver "bridge"
ERROR: no such image: https://my-git-address.git#:dockers/nginx-dev: invalid reference format

但这有点奇怪,因为当我使用相同的URL地址访问Git存储库以构建Docker映像时,一切都会顺利进行。

λ docker build --rm --compress --tag app/docker-nginx-poc https://my-git-address.git#:dockers/nginx-dev
Sending build context to Docker daemon  23.57kB
Step 1/11 : FROM phusion/baseimage:0.10.2
---> 4ca439e72536

...

---> 30a38f4f0d38
Successfully built 30a38f4f0d38
Successfully tagged app/docker-nginx-poc:latest

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

Git URL不得设置为image值,而应设置为build值:

version: '3'
services:
  nginx:
    build: https://my-git-address.git#:dockers/nginx-dev