1

I'm try to copy some file in my php/dockerfile:

COPY ./supervisord.conf /etc/supervisor                 #work
COPY ../../config/supervisor/* /etc/supervisor/conf.d   #doesn't work

WORKDIR /home/wwwroot/

What should the correct path look like? This is my structure:

|config -> supervisor -> *
|
|docker -> php -> Dockerfile
|              -> supervisord.conf
|
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Raloriz
  • 30
  • 7

1 Answers1

1

The path must be inside the context of the build; you cannot COPY ../something /something, because the first step of a docker build is to send the context directory (and subdirectories) to the docker daemon.

https://docs.docker.com/engine/reference/builder/

dockerfile has the context of its own directory, and its unable to go above. this issue has a few workarounds, for instance:

  • run the docker build . command on the directory you want to be the context, with -f path/to/Dockerfile

  • another one - if you are using docker-compose, you can pass it a different context, for example, if youre structure goes like:

.
├── docker-compose.yml
└── app
   ├── Dockerfile

then in your docker-compose file you can give it:

services:
  app:
    build:
      context: .
      dockerfile: app/Dockerfile

in this case, the context of the dockerfile will be 1 directory above. but thats seems a bit hacky to me. the correct approach is to put the dockerfile where the files you are trying to copy exists.

Efrat Levitan
  • 5,181
  • 2
  • 19
  • 40