Resource file “**/*.resx” cannot be found. (MSB3552) When building docker file - docker

When building a docker file you get the error Resource file “**/*.resx” cannot be found. (MSB3552). This occurs when you have the docker file in the same directory you are trying to copy using the COPY . . function in the docker file.

The solution is to move the docker file up to a parent directory.

Related

Using Docker COPY to copy files to container without keeping directory structure

Starting to use Docker here.
Right now im facing an issue with my project, where I need to copy multiple files from multiple directories to the docker image on start up.
Here is my current code
FROM heroiclabs/nakama:3.11.0
COPY src/*.lua /nakama/data/modules
COPY src/database/*.lua /nakama/data/modules
COPY src/managers/*.lua /nakama/data/modules
COPY src/modules/*.lua /nakama/data/modules
COPY local.yml /nakama/data
What is happening so far is that docker copies only the main.lua file from the starting directory, it either dont copy the remaining ones or copy them with the current data structure.
How can I actually copy it in order to get the lua files from database, manages and modules into the same root directory as main.lua?
To add to this, I get this error on the Nakama console that indicates that a file searched by main.lua module its not found.
{"level":"fatal","ts":"2022-04-28T21:19:51.163Z","caller":"main.go:154","msg":"Failed initializing runtime modules","error":"/nakama/data/modules/src/main.lua:2: module economyManager not found:\n\tno field package.preload['economyManager']\n\tno cached module 'economyManager', \nstack traceback:\n\t[G]: in function 'require'\n\t/nakama/data/modules/src/main.lua:2: in main chunk\n\t[G]: ?"}
So far so good, the / at the end of each COPY line did not do the trick.
Edit:
This is the full directory structure:
src
-database
--luascripts.lua
-managers
--luascripts.lua
-modules
--luascripts.lua
-main.lua
intellisense
-nakama.lua
local.yml
dorckerfile
docker-compose.yml
This helps better illustrate the error. As you can se on the log, docker its copying src directory over to nakama/data/modules, what I aim to do is to copy ONLY the content from src, but not the src directory.
Same can be said for other directories to a lesser degree, my aim is to not carry over directory structure to the destination path
Your command seems to be right, just add a trailing / to the destination docker image's path.
For example,
COPY *.lua /nakama/data/modules/
The error was on the docker-compose file, I was double mounting a volume and that was causing errors on the whole COPY operation.

Docker configuration does not find existing file?

I try to configure and run a docker file in IntelliJ Rider.
During the build, I get the following error:
Step 7/17 : COPY ["src/No.Services/No.Gf/No.Gf.Api/No.Gf.Api.csproj",
"src/No.Services/No.Gf/No.Gf.Api/"]
Error response from daemon: COPY failed: file not found in build context or excluded by .dockerignore:
stat src\No.Services\No.Gf\No.Gf.Api\No.Gf.Api.csproj: file does not exist
The file is right where the path points to. It's not exluded in .dockerignore.
I am out of options here?
Step 6 is:
Step 6/17 : WORKDIR /src
Maybe this is adding one "/src" to much and in step 7 it's finally looking for the file in /src/src/...?
I don't know your physical directory hierarchies, but I would say that the reason of the error may be the original relative path between the Dockerfile and the csproj. With the csproj location stated like src/No.Services/No.Gf/..., the Dockerfile will have to be at the same level of that src folder, for the copy to be successful.
Could you please verify this?
(If you are working with a typical dotnet solution on top of the project, setting the Dockerfile in the root of the solution may solve your error, since it will respect the folders' hierarchy.)
Regarding the other topics:
The WORKDIR command refers to the working directory in the container (reference), so, I would say that it is not the reason for your error, because it seems that, when copying, the file is not found in its source.
When the copy into the container is successful, it will probably be in a directory like src/src/No.Services/No.Gf/..., but this is after copying, inside the container.

Docker Copy failed no source files were specified

I am trying to copy a jar file in my dockerfile. whne I run build, I can see the jar under target/dockerbuild. But docker does not see the file and I am getting following error.
COPY failed: no source files were specified
My docker file has those lines for copy operation:
ENV MY_HOME=/usr/local/myhome
COPY target/dockerbuild/my.jar $MY_HOME
Why it cannot find the jar although it exists under the target.
Verify that in your .dockerignore do not have that path (target) in your exceptions
Your error looks like it could be one of the following:
The file doesn't exist in the specified path
The path doesn't exist (relative to the build context - if you use 'docker build .' then the specified path must exist relative to the current directory)
Please can you share what you run to build your docker image (so we can see the build context) and also your directory structure
That error said file target/dockerbuild/my.jar is not exist. The architecture of COPY in Dockerfile is:
COPY {file in your host} {path of target in docker image}
I had a very similar situation.
ls target/dockerbuild/my.jar
proofed that the file exists but docker build claimed that no source files were specified. However there also was a tiny hint that I did not notice for some time:
When using COPY with more than one source file, the destination must be a directory and end with a /
Though I only had one file I added the / to the copy destination and the build succeeded.

Docker accessing path outside build context for COPY

If my project is structured:
docker:
==> Dockerfile_1
source_code
In Dockerfile1 I have:
COPY //source_code
How can I add the source_code folder to my dockerfile. I keep getting a message saying that:
COPY failed: Forbidden path outside the build context: ../source_code ()
You cannot use paths outside the build context - this is done intentionally such that your container should be fully specified by the files in that directory.
What you usually want to do is simply have the Dockerfile live with the source code - there's rarely a reason to need it far from it.
Another possibility is being in the directory of your source code and using docker build -f /path/to/Dockerfile. This would be quite bothersome to use, and in my opinion, I can't see any way this would be justifiable over just placing the Dockerfile in your project root.

Dockerfile: COPY a file relative to local home

In a Dockerfile I want to copy a file relative to my local home inside the images's home.
So I have tried many variations of:
COPY "~/.m2/settings.xml" "$HOME/.m2/settings2.xml"
But I get errors like
COPY failed: stat /var/lib/docker/tmp/docker-builder635958043/~/.m2/settings.xml: no such file or directory
How can I copy a file relative to my local home inside the image?
The source for the COPY command is the build context. The build context is included in the last argument to the docker build command, often a . which means the current directory. This location is sent to the docker engine before running any steps of the Dockerfile, using a tar file, in the default/classic builder. Therefore, to keep builds running fast, you want to keep this directory small by not sending over the entire hard drive contents. This is even more important when building locally since you could potentially start sending files recursively if you were to include docker's temporary directory in the folders being sent.
All this means you should move any files you want to include in the COPY source parameter to be inside the build context, typically the same location as your Dockerfile.

Resources