Abdullah G
Abdullah G

Reputation: 157

Copy root folder to docker root path?

I want to copy /data/resources/config directory to docker image.

FROM java:latest
WORKDIR /tmp
MAINTAINER Service
COPY target/Service-1.3.jar .

RUN mkdir -p /data/resources

COPY /data/resources/config /data/resources

...

I'm getting error :

COPY failed: stat /var/lib/docker/tmp/docker-builder047879799/data/resources/config: no such file or directory

How I can copy absolute root folder to docker image ?

Upvotes: 6

Views: 29644

Answers (2)

Mohammad
Mohammad

Reputation: 1588

If your Dockerfile is in the "Data" directory then I would write

...

RUN mkdir /data /data/resources

/resources/config /data/resources

You are making directory "data" (within the container) and then inside the "data" directory make "resources" directory. In the second line you copy the local "resources" folder to the container "resources" folder.

Upvotes: 0

Mohit Mutha
Mohit Mutha

Reputation: 3001

Docker daemon runs within the context of the current directory. So you will need to copy the files to the directory from where your are running the Dockerfile.

Refer: https://github.com/moby/moby/issues/4592

Upvotes: 6

Related Questions