So I have this folder
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.
CodePudding user response:
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--
CodePudding user response:
If docker reads the Dockerfile from stdin, then no build dir is set:
https://github.com/moby/moby/issues/19197#issuecomment-170156329
If you look at the usage for docker build you'll see that the last param is: PATH | URL | - meaning you can either specify a location for your build context (dir) or it just reads the Dockerfile from stdin. In the stdin case because the build dir isn't specified it doesn't assume the current dir is what you wanted, it (as you noticed) assumes no dir at all which is why that temp dir you mentioned has just the Dockerfile. Net, this is working as designed.
I'd suggest using docker build .
instead to read the Dockerfile from the current directory.