Wondering if this is an issue with docker version CircleCI uses or an issue with docker within the CircleCI platform. Based on my knowledge of Dockerfile commands, I don’t think I did there should be a problem with the dockerfile for various versions of docker?
The same Dockerfile builds fine locally on my Mac. I’m using the VirtualBox version of Docker on Mac, not the native Docker for Mac. Current running versions
An update: using RUN + cp as workaround doesn’t seem to work either and that’s worse than COPY because it fails locally and in CircleCI. At least with COPY, it just fails in CircleCI.
Here’s the excerpt:
Step 21 : RUN cp requirements.txt /opt/monitoring
—> Running in 3408f0409405
cp: cannot stat ‘requirements.txt’: No such file or directory
The command ‘/bin/sh -c cp requirements.txt /opt/monitoring’ returned a non-zero code: 1
I also observed CircleCI uses older version of Docker than what I’m using on my Mac. I wonder if that’s a reason for the inconsistency and failure in CircleCI?
Docker version 1.8.2-circleci-cp-workaround, build 4008b9c-dirty
I would think this isn’t hard to test/reproduce. Simply have a repo with python/ruby/node dependency setup files, create a specific (absolute) directory (and later set that was working directory), and copy the dependency setup files to the created directory, then run pip/gem/npm install.
I’m not aware of how to run multiple versions of Docker (on Mac) and don’t want to mess with my installation to try to test an older version of Docker to pinpoint this problem on the local side.
To aid in debugging and reproducing the issue, I created a demo public project:
if one forks this and build in CircleCI, it should reproduce the problem. And also feel free to test the docker build locally. It works on my Mac, would be interesting to find out which local environments will build it fine and which won’t (docker for Mac/Windows, docker on linux, etc.)
Well, my bad, got it working with a tip from a colleague. And reviewing the Dockerfile reference online, it appears the “proper” way to add/copy files to a directory is to add a trailing “/” for the directory. So I was doing it improperly all along.
Interesting though how it still works for docker on Mac but not in CircleCI. Weird of docker. Perhaps different versions/implementations are more lenient or strict with the dockerfile spec.
It’s sad that (technically) from the spec docker can’t “infer” a directory like how linux does even if you don’t supply a trailing forward slash. And why is it not picky about that trailing slash in other commands like WORKDIR (just because it doesn’t deal with files I guess)?
Ah, I didn’t receive this update until after I forked your repo and reached the same conclusion.
It’s best to remember that multi-platform software is built to be consistent in its goals, but that cross-platform consistency is a “feature” that can have bugs just like any other feature. We have quite a few users who are, for instance, confused by Chrome or Firefox rendering bugs that exist only on Linux and not OS X.
For anyone else who finds this thread, note that an error such as:
stat /var/lib/docker/btrfs/subvolumes/a2f0eb7958a0f9f50e367e4e9d9a1da76182d7e9a2721e369f7f6669d7f9c011/opt/monitoring/requirements.txt: not a directory
could mean that Docker is expecting to copy a directory into another one and the source is not a directory. The more typical reading of this error message is that a parent directory in the destination doesn’t exist.