P
P
pro100ckat2019-12-16 12:52:40
Docker
pro100ckat, 2019-12-16 12:52:40

How to correctly copy files from "/" to docker image?

OS Mac
I need to move my machine's local files that are in the "/etc/scrt/ActivationCodes/AutorizationPswrd" directory to the docker image in the same directory.
In the Dockerfile I write:
FROM alpine: 3.9
RUN cd /etc
RUN mkdir scrt
RUN cd scrt
RUN mkdir ActivationCodes
RUN cd ActivationCodes
ADD /etc/scrt/ActivationCodes/AutorizationPswrd (from where locally) /etc/scrt/ActivationCodes/AutorizationPswrd (where to image)
Error when starting container: Step 7/17 : COPY /etc/scrt/ActivationCodes/AutorizationPswrd /etc/scrt/ActivationCodes/AutorizationPswrd
COPY failed: stat /var/lib/docker/tmp/docker-builder127783884/etc/scrt/ActivationCodes/ AuthorizationPswrd: no such file or directory
If I move the file from the /etc/scrt/ActivationCodes/AutorizationPswrd directory to the project folder and write
"COPY AutorizationPswrd /etc/scrt/ActivationCodes/AutorizationPswrd", the container starts without errors.
How can I access the /etc/scrt/ActivationCodes/AutorizationPswrd directory on my machine via root? I suspect that the error is due to the inability to access the root "/" of my machine, or the local path /etc/scrt/ActivationCodes/AutorizationPswrd is not recognized correctly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Karasik, 2019-12-16
@pro100ckat

I suspect that the error occurs due to the inability to access the root "/" of my machine

That's right, add/copy in a dockerfile only has access to files inside the directory.
So it is correct to copy the files to the project folder.
Or, if you really want to, run docker build from "/".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question