Sergey Onishchenko
Sergey Onishchenko

Reputation: 7851

Docker-compose exclude from volume and copy

A few lines from docker-compose.yml

   volumes:
      - ./yii-application:/app/yii-application
      - /app/yii-application/common/config/

First line adds to the volume an entire application. The second one makes some sort of exclude of config folder, so I do not need my config from host machine.

A few lines from Dockerfile

COPY ./config-${APP_ENV}/common /app/yii-application/common/config

Instead of COPY I tried

RUN cp -a /app/config-${APP_ENV}/common/. /app/yii-application/common/config

It does not work either.

Upvotes: 1

Views: 2462

Answers (2)

Sergey Onishchenko
Sergey Onishchenko

Reputation: 7851

I moved the config files out of volume directory. So, now the volume looks like this

   volumes:
      - ./yii-application:/app/yii-application

Config files in

./

Upvotes: 0

Luminance
Luminance

Reputation: 918

I think there is an issue in the order of the commands that are being executed:

  1. When you are building and image with Dockerfile, you are coping the code inside dir /app/yii-application/common/config.

  2. Then, you are mounting a volume: volumes: /app/yii-application/common/config/
    and overwriting the existing dir with an empty dir that serves as a volume.

You need to work around that issue.

Upvotes: 1

Related Questions