Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker COPY cannot find the file

So I have this folder

img1

In which I run (using Powershell)

Get-Content Dockerfile | docker build -

But I get the following error :

 => ERROR [8/8] COPY docker-entrypoint.sh /                                                                            
 0.0s
 ------
 > [8/8] COPY docker-entrypoint.sh /:
 ------
 failed to compute cache key: "/docker-entrypoint.sh" not found: not found

This obviously has something to with an absolute path problem, but what is the intended fix for this ? I've tried multiple things from stackoverflow without success (changing CRLF to LF, using . instead of /, etc).

Thanks.


1 Answers

When you build using docker build - there is no build context and you can't use COPY or ADD, unless they copy from a URL.

Since there is no context, a Dockerfile ADD only works if it refers to a remote URL.

You need a context, so you should use

docker build -t myimage .

instead.

More info here https://docs.docker.com/engine/reference/commandline/build/#build-with--

like image 68
Hans Kilian Avatar answered Jul 19 '26 17:07

Hans Kilian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!