Skip to content

yarn install fails inside a Docker Container with --userns-remap enabled #1750

Closed
@lawliet89

Description

@lawliet89

Do you want to request a feature or report a bug?

Bug

What is the current behavior?
Running yarn install in a Docker container with the daemon having --userns-remap enabled fails with the following:

  Error: https://registry.yarnpkg.com/immutable/-/immutable-3.8.1.tgz: EINVAL: invalid argument, chown '/root/.yarn-cache/npm-immutable-3.8.1/package.json'
      at Error (native)

If the current behavior is a bug, please provide the steps to reproduce.

Start the Docker daemon with --userns-remap enabled.

Then try to run or build a Docker image with yarn install:

# Inside the Docker container
$ id
uid=0(root) gid=0(root) groups=0(root)
$ strace -o strace.log -ff yarn install
$ tail yarn-error.log 
Trace: 
  Error: https://registry.yarnpkg.com/immutable/-/immutable-3.8.1.tgz: EINVAL: invalid argument, chown '/root/.yarn-cache/npm-immutable-3.8.1/package.json'
      at Error (native)
$ grep chown strace.log.*
strace.log.202:chown("/root/.yarn-cache/npm-bowser-1.4.6/package.json", 502, 20) = 0
strace.log.202:chown("/root/.yarn-cache/npm-bowser-1.4.6/.npmignore", 502, 20) = 0
strace.log.202:chown("/root/.yarn-cache/npm-alt-utils-1.0.0/package.json", 501, 20) = 0
strace.log.202:chown("/root/.yarn-cache/npm-immutable-3.8.1/package.json", 116435139, 1876110778) = -1 EINVAL (Invalid argument)
strace.log.202:chown("/root/.yarn-cache/npm-bowser-1.4.6/LICENSE", 502, 20) = 0
strace.log.202:chown("/root/.yarn-cache/npm-react-15.3.2/package.json", 616931727, 1876110778) = -1 EINVAL (Invalid argument)
strace.log.202:chown("/root/.yarn-cache/npm-alt-0.18.6/package.json", 502, 20) = 0
strace.log.202:chown("/root/.yarn-cache/npm-react-addons-css-transition-group-15.3.2/package.json", 616931727, 1876110778) = -1 EINVAL (Invalid argument)
strace.log.202:chown("/root/.yarn-cache/npm-numeral-1.5.3/package.json", 501, 20) = 0
strace.log.203:chown("/root/.yarn-cache/npm-alt-utils-1.0.0/lib/ActionListeners.js", 501, 20) = 0
strace.log.203:chown("/root/.yarn-cache/npm-alt-utils-1.0.0/lib", 501, 20) = 0
strace.log.204:chown("/root/.yarn-cache/npm-moment-2.15.1/package.json", 1000, 1000) = 0
strace.log.204:chown("/root/.yarn-cache/npm-react-addons-update-15.3.2/package.json", 616931727, 1876110778) = -1 EINVAL (Invalid argument)
strace.log.205:chown("/root/.yarn-cache/npm-bowser-1.4.6/README.md", 502, 20) = 0
strace.log.205:chown("/root/.yarn-cache/npm-alt-utils-1.0.0/.npmignore", 501, 20) = 0
strace.log.205:chown("/root/.yarn-cache/npm-classnames-2.2.5/package.json", 501, 20) = 0
strace.log.205:chown("/root/.yarn-cache/npm-lodash-4.16.4/package.json", 501, 20) = 0

I am running --userns-remap=teamcity:teamcity with the following information:

$ id teamcity
uid=1001(teamcity) gid=1001(teamcity) groups=1001(teamcity),999(docker)
$ cat /etc/subuid
ubuntu:100000:65536
teamcity:165536:65536
$ cat /etc/subgid
ubuntu:100000:65536
teamcity:165536:65536

What is the expected behavior?
Successful installation

I believe this is the same issue encountered in #1485, #918 and #869. If I do npm install, it installs successfully.

If I run the container with --userns=host, it runs successfully. So I can only conclude this issue is due to the Linux user namespace.

Please mention your node.js, yarn and operating system version.

$ node --version
v6.7.0
$ uname -a
Linux 2970f7786932 3.13.0-100-generic #147-Ubuntu SMP Tue Oct 18 16:48:51 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

strace:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions