'cannot copy to non-directory: Docker compose build
I am using docker-compose build to build the image but I am always getting below error for the command ADD . /. in my Dockerfile.it
=> ERROR [sample/test-example:latest 8/8] ADD . /.
------
> [sample/test-example:latest 8/8] ADD . /.
------
failed to solve: rpc error: code = Unknown desc = cannot copy to non-directory: /var/lib/docker/overlay2/ul1wueihd47ieq2tzmd2rwopq/merged/lib
I am using below versions
Docker Desktop version : 4.5.0
Docker Engine : 20
MacOS
Solution 1:[1]
ADD copies files, folders, or remote URLs from source to the dest path in the image's filesystem.
ADD source dest
Eg:
ADD hello.txt /absolute/path
ADD hello.txt relative/to/workdir
In your case,
ADD . /. does not mention any valid destination. /. is a root path. If you want to copy to the current work directory use ADD . ./ or to any other folder use ADD . <path to folder>.
Note: When adding multiple source files or directories, there must be a / at the end of the destination directory.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
