When building my Docker image I need to copy all of the files in the same directory in to the Docker image.
I attempted to do this
ADD ./* $HOME/src
RUN ls $HOME/src
but it doesn't seem to work
ls: cannot access /root/src: No such file or directory
How would I go about copying all of the current directory and subdirectories in to my docker image while building?
If you want to copy the /tmp/foo directory from a container to the existing /tmp directory on your host. If you run docker cp in your (home) directory on the local host: $ docker cp compassionate_darwin:tmp/foo /tmp Docker creates a /tmp/foo directory on your host.
Docker Dockerfiles COPY InstructionThe COPY instruction copies new files or directories from <src> and adds them to the filesystem of the container at the path <dest> . Multiple <src> resource may be specified but they must be relative to the source directory that is being built (the context of the build).
Just add / at the end of src in ADD statement.
ADD ./* $HOME/src/
I was building the images using docker build - < Dockerfile
which apparently doen't send the build context so things can't be copied. After changing to docker build .
and adding the / like MB11 suggested the build worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With