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?
Related
I have a very strange issue with copying the contents of subdirectories to a Docker container.
This is the directory structure:
Note: There are two Dockerfiles, I use the one on the upper level for test purposes. Ignore the one in the WebApp folder.
I want to copy the directories Bilder and JSON to the container, including all contents, but it doesn't work. The folders in the container will be empty. However, copying the Testdir does indeed work.
This is part of my Dockerfile:
FROM python:3.7-buster
# -- Init --
RUN mkdir -p /app/src
WORKDIR /app/src
ADD WebApp/Testdir ./Testdir #works
ADD WebApp/Bilder ./Bilder #doesn't work
CMD ["sleep", "50"] #to check contents
I build the image as part of a docker-compose.yml file with
docker-compose build test
Does anyone have a clue what's happening here? I've been searching for a solution for quite some time...
If anyone is interested by why this was a problem: it actually had nothing to do with Docker. I was working on a cluster that was not synchronizing my local files to the server correctly, so I solved this issue by checking every time whether the files were actually copied from my local machine to the cluster. Just in case someone has a similar issue, you might be advised to check whether the file accessibility could be the problem.
I'm trying to build a docker image
I get this error
sudo docker build . -t django-demo
error checking context: 'no permission to read from '/home/benny/.ICEauthority''
any ideas why this is happening?
--------------------------
ubuntu 18.04
Docker version 18.09.9
Create a new directory, place your Dockerfile in this new directory and then run your sudo docker build . -t django-demo command from that directory. This should solve your problem. Found related problems and solution in this external thread.
Generally to solve this kind of problem you should add a .dockerignore file in which you list all the files you don't want to be sent to the build's context (ie. the files that docker don't need to build your image).
In your case simply creating a .dockerignore with the following content should solve the issue :
.ICEauthority
Note that specifically in your case though, you should not run your docker build command directly from your home directory, because all the content of your home is being sent to the build's context (which is heavy, might make you run out of disk space or generate permission issues).
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
Is it possible to copy multiple files to different locations in a Dockerfile?
I'm looking to go from:
COPY outputs/output/build/.tools /root/.tools
COPY outputs/output/build/configuration /root/configuration
COPY outputs/output/build/database/postgres /root/database/postgres
I have tried the following, but no joy:
COPY ["outputs/output/build/.tools /root/.tools","outputs/output/build/configuration /root/configuration","outputs/output/build/database/postgres /root/database/postgres"]
Not sure if this is even possible.
Create a file .dockerignore in your docker build context directory. Create a soft link (ln) of the root directory you want to copy and exclude the directories you don't want in your .dockerignore.
In your case, you don't need the soft link as the directory is already in the docker build context. Now, add the directories in the .dockerignore file that you don't want eg. if you don't want bin directory you can do that as,
# this is .dockerignore file
outputs/output/build/bin*
Finally in your Dockerfile,
COPY outputs/output/build/ /root/
Details are here.
it looks like you are trying to do bash style [] brace expansion
RUN command uses sh NOT bash
see this SO article discussing it
Bash brace expansion not working on Dockerfile RUN command
or the docker reference
https://docs.docker.com/engine/reference/builder/#/run
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.