Docker ADD giving error "No source files were specified" - docker

Dockerfile is failing on the following line:
ADD ./test-web-app/build/libs/test-web*.war /app/test-web.war
Error Step 8/29 : COPY ./test-web-app/build/libs/test-web*.war
/app/micro-service.war No source files were specified
This is the first time I am working on Docker builds. How do I debug this issue? Is there a way to echo if the host file is existing by a command ?

be sure that the path of the file is accessible where the Dockerfile is. When you run the build, the . folder is where the Dockerfile is. So you directory structure has to be something similar to this:
.
..
Dockerfile
test-web-app (folder)
To be sure that the war file is accessible try to list the file (on your host machine) for example.
$ ls ./test-web-app/build/libs/test-web*.war

Related

Cant open a file by it's relative path while the code running from docker container

I'm looking for help in the issue I have.
In my code I'm trying to open a config file by it's relative path
with open("../config/config.json") as json_config:
This part works great when I'm running it locally (either command line or IDE)
The folder structure looks like this (the running code is in convertor folder):
When I'm trying to run the same code from docker container , I'm getting
FileNotFound Error.
FileNotFoundError: [Errno 2] No such file or directory: '../config/config.json'
my Docker file looks like
...
RUN mkdir /app
WORKDIR /app
COPY . .
...
The config.json is correctly copied to container (all the project correctly being copied)
Thanks for helping here !
with open("config/config.json") as json_config:
Forgot that the code is running from the root :)

Unable to replace files in docker image with ADD or COPY

I am trying to replace some files in a folder in a docker image. I am using the following command inside Dockerfile:
COPY /home/adietz/Work/20_BSP/Jenkins/venvs/linux_selenium/lib/python2.7/site-packages/browsermobproxy /usr/local/lib/python2.7/dist-packages/browsermobproxy
which results in an error
Step 4/12 : COPY /home/adietz/Work/20_BSP/Jenkins/venvs/linux_selenium/lib/python2.7/site-packages/browsermobproxy /usr/local/lib/python2.7/dist-packages/browsermobproxy
lstat home/adietz/Work/20_BSP/Jenkins/venvs/linux_selenium/lib/python2.7/site-packages/browsermobproxy: no such file or directory
Replacing COPY with ADD results in the same error. Also the following command
COPY /home/adietz/Work/20_BSP/Jenkins/venvs/linux_selenium/lib/python2.7/site-packages/browsermobproxy /usr/local/lib/python2.7/dist-packages/
and gives identical(!) error.
Both paths are folders. The folder in the docker image already exists; I just want to replace the files.
What am I doing wrong here...?
It seems you cannot use absolute paths in the COPY command AND you can only copy files which are inside the folder you are running the docker command.
So to copy these files you have to do e.g. the following steps
cp -r /home/adietz/Work/20_BSP/Jenkins/venvs/linux_selenium/lib/python2.7/site-packages/browsermobproxy .
and then add to the Dockerfile:
COPY browsermobproxy/ /usr/local/lib/python2.7/dist-packages/
A symbolic link also does not work...
I had this same issue and realized that COPY or ADD won't work with node_modules that are referenced instead of directly installed into the project. When I switched this it worked for me.

Docker Copy - Windows

I am currently trying to copy a folder and its sub directories to a docker container but all that copies in is the folder structure "obj\Docker\empty"
I am running the command in Powershell from D:\Sites\Web.API and the command is:
docker cp . eac334ba8bf6:./inetpub/wwwroot/Web.API.
My .dockerignore file has this in it
!obj\Docker\publish\*
!obj\Docker\empty\
I'm pretty new to this so may be something silly but currently all out of ideas !
I think the issue is file system permissions. Have you tried to copy it somewhere else?

How can i ADD directory using dockerfile from remote repository to current host?

I'm using the following command in my docker file for OpenShift, unix terminal, trying to copy directory "test" to the container that i build, under "/apps/" directory:
ADD https://stash.abc.com:2000/dir_name/repos/test /apps/test/
The result is that it creates a file named "test" under a new directory "/apps/test/".
I also tried:
ADD https://stash.abc.com:2000/dir_name/repos/test/* /apps/test/
And this:
ADD https://stash.abc.com:2000/dir_name/repos/test /apps/
Which resulted in created file named "*"
Am I doing something wrong?

Dockerhub automated build fails, "not a directory" when adding file

I am trying to use docker hub to automatically build something that builds fine locally. It fails saying:
Build process failed: stat /var/lib/docker/aufs/mnt/1be9db483fa6f3de2596b5261e7c450de8df503185e579278396f14ba179c257/bin/run.sh: not a directory
You can view the build itself here:
https://hub.docker.com/r/zbyte64/rethinkdb-tlsproxy/builds/bjclhq33kgwxxvn6nbfsgyh/
run.sh is in the same directory as Dockerfile, it seems the build path on dockerhub is different then where it stores the Dockerfile.
I have tried the following variations:
COPY run.sh /bin
ADD ./run.sh /bin
The COPY command (on Dockerhub's Docker version) expects the target file on the right hand side, not just the target directory. The following command should work for you even on Dockerhub.
COPY run.sh /bin/run.sh
Or if you want to use ADD, include the trailing slash.
ADD ./run.sh /bin/
What is actually happening? From https://docs.docker.com/engine/reference/builder/#add :
ADD src dest
"If dest does not end with a trailing slash, it will be considered a regular file and the contents of src will be written at dest."
Without the trailing slash on /bin, it expects run.sh to be a directory being copied to directory /bin.
I don't know why, but dockerhub wants the first argument of COPY or ADD to be a directory - not a file. I am running Docker 1.9.1 locally and that is not the case. I switched the Dockerfile to copy a resource directory instead of individual files and things started to work.

Resources