Reputation: 1536
I am trying to perform some automation to while build my docker image. Below is my code run in Windows 8, Kitematic, Virtual Box:
FROM node:6
# Create directory
RUN mkdir -p /tempDir && mkdir -p /tempDir/built && mkdir -p /data
# Setup build environment
COPY . /tempDir
RUN npm install -g gulp typings
# Build from source
WORKDIR /tempDir
RUN npm install && typings install && gulp build
Up to here, everything is fine, success to build my typescript to javascript in /tempDir/built directory. I bash into my container, it look like this:
tempDir/gulpfile.js
tempDir/typings
tempDir/src
tempDir/built
My next step is to move this built folder to another directory then delete tempDir. My problem is that COPY command not work as I expected.
COPY built/* /data/
I keep on getting error like 'no such file or directory' or 'lstat built/: no such file or directory'. I tried ./built, ./built/, built/, /tempDir/built/, and other still getting the same error. Anyone can help on this?
Upvotes: 7
Views: 15729
Reputation: 5797
COPY
copies files from your host filesystem into the container. It looks like you want to copy files from one directory in the container to another. For that you need to use RUN
and cp
RUN cp -r built/* /data/
Since you will be removing the /tempDir/
directory, you can speed things up a bit by renaming the directory:
RUN mv built /data
This way you don't have to copy data around and then delete the originals.
Upvotes: 6
Reputation: 4821
you are trying to copy something that's in your container and so COPY
will not work because it is specific to your Host --> Container.
Instead you will have to run a bash command inside your container.
RUN cp -rf built /data/
Upvotes: 3