0

I have a project folder containing my docker compose file. This references a child folder as a sub project.

When running docker compose an ADD adds the docker-compose location and not the sub directory as expected.

project/docker-compose.yml

db:
  image: postgres
api:
  build: ./api
  command: bundle exec rails s --port 3000 --binding 0.0.0.0
  ports:
    - "3000:3000"
  links:
    - db
  volumes:
    - .:/myapp

Here is the api dockerfile.

FROM ruby:2.2.3

RUN apt-get update -qq && apt-get install -y build-essential

ENV APP_HOME /myapp
RUN mkdir $APP_HOME
WORKDIR $APP_HOME

ADD Gemfile* $APP_HOME/
RUN bundle install

ADD . $APP_HOME # Expect this to add project/api to /myapp but adds project
tgandrews
  • 155
  • 1
  • 1
  • 7

1 Answers1

0

The fix was to map the volume correctly in the docker compose file.

db:
  image: postgres
api:
  build: ./api
  command: bundle exec rails s --port 3000 --binding 0.0.0.0
  ports:
    - "3000:3000"
  links:
    - db
  volumes:
    - ./api:/myapp
tgandrews
  • 155
  • 1
  • 1
  • 7
  • Interesting that you worked it out. However, I do not fully understand how that can make a difference. What happens if you leave out the `volumes:` declaration altogether? [Because I would think that `ADD` is a build-time command which means run-time volume mappnigs do not make a difference?] – linux-fan Nov 08 '19 at 21:16