Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker compose - ignore build context path

I have docker-compose.yml file with build context property specified like this:

version: '3'
services:
  my-service:
    container_name: my-service
    image: my-service
    build:
      context: foo
    ports:
    - 8088:8088

  # other services

When I run docker-compose up locally, build context does exist and everything works fine. However, my CI server is configured to use the same docker-compose.yml file but there is no build context (images are copied as .tar archive via SSH and then loaded via docker load). Now I've got an error:

ERROR: build path /foo either does not exist, is not accessible, or is not a valid URL.

So I've tried to find a way to suppress looking for this build context when running docker-compose up (I don't want to build images cause they are already up-to-date), but docker-compose up --no-build does not work. Any ideas?

like image 678
k13i Avatar asked Nov 20 '18 08:11

k13i


2 Answers

docker-compose.override.yml is good solution in this case. You may override only build block and this is not hard to mantain as two independent files.

docker-compose.override.yml:

version: '3'
  services:
    my-service:
      build:
        context: foo

docker-compose.yml

version: '3'
  services:
    my-service:
      container_name: my-service
      image: my-service
      ports:
        - 8088:8088

See https://docs.docker.com/compose/extends/

like image 180
dngnezdi Avatar answered Sep 20 '22 22:09

dngnezdi


I posted your issue as a feature request on the docker-compose repository. Let's see how it progresses:

https://github.com/docker/compose/issues/7674

Meanwhile, you will have to workaround this by modifying your CI script that does the docker-compose up --no-build so it does the mkdir -p ... that you need.

like image 41
zeehio Avatar answered Sep 21 '22 22:09

zeehio