Error with Node:8-alpine docker image on AWS using an M5 instance type

cli
help-wanted
priority:low
triaged

(Raúl Gomis) #1

What I Wanted to Do

We migrated our EC2 Instances from M4 to M5 in Bitbucket Pipelines.

What Happened Instead

We had some customers complaining about having errors in their builds: https://bitbucket.org/site/master/issues/16334/pipelines-failing-with-could-not-get-uid

Node 8 alpine image does not appear to work on AWS m5 instances.

Reproduction Steps

docker container run -it node:8-alpine /bin/sh -c ‘npm -g’

Details

Terminal logs:

Error: could not get uid/gid
[ 'nobody', 0 ]

    at /usr/local/lib/node_modules/npm/node_modules/uid-number/uid-number.js:37:16
    at ChildProcess.exithandler (child_process.js:282:5)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:557:12)
TypeError: Cannot read property 'get' of undefined
    at errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:83:20
    at cb (/usr/local/lib/node_modules/npm/lib/npm.js:224:22)
    at /usr/local/lib/node_modules/npm/lib/npm.js:262:24
    at /usr/local/lib/node_modules/npm/lib/config/core.js:81:7
    at Array.forEach (<anonymous>)
    at /usr/local/lib/node_modules/npm/lib/config/core.js:80:13
    at f (/usr/local/lib/node_modules/npm/node_modules/once/once.js:25:25)
    at afterExtras (/usr/local/lib/node_modules/npm/lib/config/core.js:178:20)
    at Conf.<anonymous> (/usr/local/lib/node_modules/npm/lib/config/core.js:236:22)
    at /usr/local/lib/node_modules/npm/node_modules/uid-number/uid-number.js:39:14
    at ChildProcess.exithandler (child_process.js:282:5)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205
  if (npm.config.get('json')) {
                 ^

TypeError: Cannot read property 'get' of undefined
    at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
    at emitOne (events.js:116:13)
    at process.emit (events.js:211:7)
    at process._fatalException (bootstrap_node.js:378:26)

Strace logs:

read(8, "\1\0\0\0\0\0\0\0", 1024)       = 8
stat("/usr/local/lib/node_modules/npm/node_modules/uid-number", {st_mode=S_IFDIR|0755, st_size=101, ...}) = 0
stat("/usr/local/lib/node_modules/npm/node_modules/uid-number/get-uid-gid.js", {st_mode=S_IFREG|0755, st_size=644, ...}) = 0
lstat("/usr/local/lib/node_modules/npm/node_modules/uid-number/get-uid-gid.js", {st_mode=S_IFREG|0755, st_size=644, ...}) = 0
socketpair(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0, [12, 13]) = 0
socketpair(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0, [14, 15]) = 0
socketpair(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0, [16, 17]) = 0
pipe2([18, 19], O_CLOEXEC)              = 0
rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1 RT_2], [], 8) = 0
read(4, "*", 1)                         = 1
rt_sigaction(SIGCHLD, {sa_handler=0x557d5d900ad0, sa_mask=~[RTMIN RT_1 RT_2], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fda9929f722}, NULL, 8) = 0
write(5, "*", 1)                        = 1
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, ~[], [], 8)   = 0
fork()                                  = 21
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
close(19)                               = 0
read(18, "", 4)                         = 0
close(18)                               = 0
close(13)                               = 0
ioctl(12, FIONBIO, [1])                 = 0
close(15)                               = 0
ioctl(14, FIONBIO, [1])                 = 0
close(17)                               = 0
ioctl(16, FIONBIO, [1])                 = 0
epoll_ctl(3, EPOLL_CTL_ADD, 12, {EPOLLIN, {u32=12, u64=12}}) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 14, {EPOLLIN, {u32=14, u64=14}}) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 16, {EPOLLIN, {u32=16, u64=16}}) = 0
epoll_wait(3, [{EPOLLIN, {u32=16, u64=16}}], 1024, -1) = 1
read(16, "[ 'nobody', 0 ]\n", 65536)    = 16
epoll_wait(3, [{EPOLLIN|EPOLLHUP, {u32=12, u64=12}}], 1024, -1) = 1
read(12, "", 65536)                     = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=21, si_uid=0, si_status=SIGSEGV, si_utime=4, si_stime=1} ---
read(4, "*", 1)                         = 1
write(7, "\250\210a^}U\0\0\21\0\0\0\0\0\0\0", 16) = 16
write(5, "*", 1)                        = 1
rt_sigreturn({mask=[]})                 = 0
epoll_ctl(3, EPOLL_CTL_DEL, 12, 0x7ffef7ad1bec) = 0
close(12)                               = 0
epoll_wait(3, [{EPOLLIN|EPOLLHUP, {u32=16, u64=16}}, {EPOLLIN|EPOLLHUP, {u32=14, u64=14}}, {EPOLLIN, {u32=6, u64=6}}], 1024, -1) = 3
read(16, "", 65536)                     = 0
epoll_ctl(3, EPOLL_CTL_DEL, 16, 0x7ffef7ad21ac) = 0
close(16)                               = 0
read(14, "", 65536)                     = 0
epoll_ctl(3, EPOLL_CTL_DEL, 14, 0x7ffef7ad21ac) = 0
close(14)                               = 0
read(6, "\250\210a^}U\0\0\21\0\0\0\0\0\0\0", 512) = 16
wait4(21, [{WIFSIGNALED(s) && WTERMSIG(s) == SIGSEGV && WCOREDUMP(s)}], WNOHANG, NULL) = 21
rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1 RT_2], [], 8) = 0
read(4, "*", 1)                         = 1
rt_sigaction(SIGCHLD, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7fda9929f722}, NULL, 8) = 0
write(5, "*", 1)                        = 1
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
write(11, "Error: could not get uid/gid\n[ '"..., 509Error: could not get uid/gid
[ 'nobody', 0 ]

    at /usr/local/lib/node_modules/npm/node_modules/uid-number/uid-number.js:37:16
    at ChildProcess.exithandler (child_process.js:282:5)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:557:12)
) = 509
uname({sysname="Linux", nodename="dba91fdc3e5d", ...}) = 0
uname({sysname="Linux", nodename="dba91fdc3e5d", ...}) = 0
write(11, "TypeError: Cannot read property "..., 1054TypeError: Cannot read property 'get' of undefined
    at errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:83:20
    at cb (/usr/local/lib/node_modules/npm/lib/npm.js:224:22)
    at /usr/local/lib/node_modules/npm/lib/npm.js:262:24
    at /usr/local/lib/node_modules/npm/lib/config/core.js:81:7
    at Array.forEach (<anonymous>)
    at /usr/local/lib/node_modules/npm/lib/config/core.js:80:13
    at f (/usr/local/lib/node_modules/npm/node_modules/once/once.js:25:25)
    at afterExtras (/usr/local/lib/node_modules/npm/lib/config/core.js:178:20)
    at Conf.<anonymous> (/usr/local/lib/node_modules/npm/lib/config/core.js:236:22)
    at /usr/local/lib/node_modules/npm/node_modules/uid-number/uid-number.js:39:14
    at ChildProcess.exithandler (child_process.js:282:5)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
) = 1054
uname({sysname="Linux", nodename="dba91fdc3e5d", ...}) = 0
uname({sysname="Linux", nodename="dba91fdc3e5d", ...}) = 0
writev(2, [{iov_base="", iov_len=0}, {iov_base="/usr/local/lib/node_modules/npm/"..., iov_len=114}], 2/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205
  if (npm.config.get('json')) {
                 ^
) = 114
writev(2, [{iov_base="\n", iov_len=1}, {iov_base="TypeError: Cannot read property "..., iov_len=276}], 2
TypeError: Cannot read property 'get' of undefined
    at process.errorHandler (/usr/local/lib/node_modules/npm/lib/utils/error-handler.js:205:18)
    at emitOne (events.js:116:13)
    at process.emit (events.js:211:7)
    at process._fatalException (bootstrap_node.js:378:26)) = 277
writev(2, [{iov_base="\n", iov_len=1}, {iov_base=NULL, iov_len=0}], 2
) = 1
futex(0x7fda964e59e4, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x557d5e6185a4, FUTEX_WAKE_PRIVATE, 1) = 1
munmap(0x7fda964e6000, 8400896)         = 0
munmap(0x7fda95ce3000, 8400896)         = 0
munmap(0x7fda954e0000, 8400896)         = 0
munmap(0x7fda94cdd000, 8400896)         = 0
exit_group(7)                           = ?
+++ exited with 7 +++

Platform Info

All alpine versions. More info: https://github.com/nodejs/docker-node/issues/813


(Kat Marchán) #2

Triage note: It looks like this has a workaround if you use --unsafe-perms. The RFC about changing how we handle running npm as root is probably relevant here.

Also referencing the old npm issue:


(system) #3

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