Docker build fails with nonsensical EPERM: operation not permitted, copyfile

Also resolved by pinning nodejs at 12.18.4.

curl -o nodejs.deb ; apt-get install -y ./nodejs.deb ; rm nodejs.deb

can you please tell me how to force that specific version?


In our dockerfile we used to have:

RUN wget -qO - | apt-key add -
RUN echo "deb stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN set -ex \
    && wget --quiet -O - | bash - \
    && apt-get install -y --no-install-recommends nodejs yarn \
    && rm -rf /var/lib/apt/lists/*

But to pin the version, I adapted the code in the official nodejs docker image, so replaced it with this:

# # NodeJS config - installing a specific version, adapted from the docker node repo:
RUN for key in \
    4ED778F539E3634C779C87C6D7062848A1AB005C \
    94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
    71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
    8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
    C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
    C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \
    DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
    A48C2BEE680E841632CD4E44F07496B3EB3C1762 \
    108F52B48DB57BB0CC439B2997B01419BD92F80A \
    B9E2F5981AA6E0CD28160D9FF13993A75599653C \
  ; do \
    gpg --batch --keyserver hkp:// --recv-keys "$key" || \
    gpg --batch --keyserver hkp:// --recv-keys "$key" || \
    gpg --batch --keyserver hkp:// --recv-keys "$key" ; \
  done \
  && curl -fsSLO --compressed "$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz" \
  && curl -fsSLO --compressed "$NODE_VERSION/SHASUMS256.txt.asc" \
  && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
  && grep " node-v$NODE_VERSION-linux-x64.tar.gz\$" SHASUMS256.txt | sha256sum -c - \
  && tar -xzf "node-v$NODE_VERSION-linux-x64.tar.gz" -C /usr/local --strip-components=1 --no-same-owner \
  && rm "node-v$NODE_VERSION-linux-x64.tar.gz" SHASUMS256.txt.asc SHASUMS256.txt \
  && ln -s /usr/local/bin/node /usr/local/bin/nodejs \
  # smoke tests
  && node --version \
  && npm --version

Added bonus: our docker image shrank by 40mb!


Upgrading the Docker engine used by setup_remote_docker resolved the issue for me, too. Thank you!

I appreciated it!

Just FYI, I tested upgrading the `setup_remote_docker’ commands version of docker engine and that fixes for me too if I move back to nodejs 12.19.0

Thanks. This worked for me. @d_marm

1 Like

I opened an issue with CircleCI about this. They’re claiming it’s an upstream problem with yarn.

Could you link to the issue you opened?

No, but there’s a fix. Upgrading the Docker Engine to a moder version (I’m using 19.x now) fixes the permissions issue.

Yeah, I tried the fix, it worked for me. I’m just wondering whether I should pin Docker Engine on all my repos to something non-default, or whether it’s worth waiting for CircleCI to actually change their default. That’s why I wanted to see their response to the issue to gauge what their intention is.

1 Like

Pinning the version of Node.js to 12.18.4 worked for me. Thank you!

1 Like

Hi All,

As an update, we were able to locate the root of this issue. Nodes Docker Image is officially supported on Docker version 1.9.1. By default, when using the setup_remote_docker key, if a versions is not specified, CircleCI uses Docker version 17.09.0. You will need to specify a Docker version using the version attribute. You can find more information in this support article : Docker build fails with EPERM: operation not permitted, copyfile..... .

We are not currently planning on updating our default docker version at this time.


This has worked for me, thanks for the solution Henna.

Thanks for the blog post, it works!

In our case the build was randomly failing, once it worked, once it didn’t. In both case it was docker 17.09.0-ce + yarn 1.22.5. I checked the logs and nothing changed between. It seems that there must have been a bug in 17.09.0-ce which is fixed in 19.03.13. As it’ll come up for other users, I recommend updating the default images, but at least this thread is found by a Google search.

BTW, that note about the old Docker version is unrelated, 1.x in Docker was ages ago.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.