3

I`d like to know is there good way to move folder/file, which is outside the building context, to Inside the build context when docker-compose build. Is that possible to solve by using init.sh or startup.sh by using Docker-compose?

When I build this Dockerfile,

….
# set assets to inside docker container
COPY ../../frontend/src/assets /var/www/assets
….

And I did docker-compose build However I got error about this

Step 19/21 : COPY ../../frontend/src/assets /var/www/assets
ERROR: Service 'test' failed to build: COPY failed: Forbidden path outside the build context: ../../frontend/src/assets ()

If I execute “ cp -rf ../../frontend/src/assets ./“ before build and change path of folder in Dockerfile, this is no problem, But if I could, I want to make this less operation.

O.Takashi
  • 73
  • 2
  • 12
  • See here: https://stackoverflow.com/a/34392052/609290 – DazWilkin Mar 12 '19 at 03:53
  • 1
    @DazWilkin Thanks @DazWilkin Thanks I'll add `command: bash -c "cp -r ` in docker-compose.yml :) – O.Takashi Mar 12 '19 at 04:38
  • I think you'd be better placed running the build from a parent directory of the files you wish to copy and then explicitly specifying the Dockerfile with `--file=` as described in the comments on that question. – DazWilkin Mar 12 '19 at 04:53
  • @DazWilkin If it was just one Dockerfile, I’ll do that. But in this time, we have some Dockerfiles and we need to build at specific directory. – O.Takashi Mar 12 '19 at 07:20

0 Answers0