Repository navigation
Error with Node:8-alpine docker image on AWS using an M5 instance type #813
Copy link
Copy link
Closed
Description
Problem:
Node 8 alpine image does not appear to work on AWS m5 instances.
Command:
docker container run -it node:8-alpine /bin/sh -c 'npm -g'
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 +++
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
chorrell commentedon Jul 11, 2018
Can you provide the output of
docker version?raulgomis commentedon Jul 13, 2018
docker versionLaurentGoderre commentedon Jul 16, 2018
Is it me or this seems like an error specific to npm?
raulgomis commentedon Jul 24, 2018
I think there is something between node / alpine (musl) and the new Hyperv on AWS M5s:
docker run -it node:8-alpine sh -c "node -e 'process.setgid(0)'"returns a "Segmentation fault (core dumped)" in M5s.
So, in summary, those are all tests in an AWS M5 instance:
Test 1: setgid node
docker run -it node:8-alpine sh -c "node -e 'process.setgid(0)'"-> "Segmentation fault"docker run -it node:10-alpine sh -c "node -e 'process.setgid(0)'"->"Segmentation fault" (although in node:10-alpine is not displayed, but segmentation fault occurs)Test 2: setgid npm
docker container run -it node:8-alpine /bin/sh -c 'npm -g'anddocker container run -it node:10-alpine /bin/sh -c 'npm -g'Test 3: setgid c++
This works:
raulgomis commentedon Jul 24, 2018
Root cause seems to be: https://wiki.musl-libc.org/functional-differences-from-glibc.html#Thread_stack_size
There three possible solutions:
LaurentGoderre commentedon Jul 24, 2018
Can you try node 10? I've read that this was fixed in Alpine 3.7
raulgomis commentedon Jul 25, 2018
It still fails in
node:10-alpine(alpine 3.8)Details:
chorrell commentedon Jul 25, 2018
Alternatively, you should switch to the
slim(Debian) variant until this get's fixe upstream by the Alpine team.carlosmmelo commentedon Sep 6, 2018
I followed the
lib/stack-fix.soyou provided on the dockerfile link above.And also the Debien non root version (Jessie)
I'm still getting this issue after upgraded my instance.
Anyone else has another workaround? this is been very annoying.
dysinger commentedon Oct 4, 2018
Issue #3 is still prematurely closed with lots of "me too" comments
tianon commentedon Oct 17, 2018
Looks like this is the root cause of the Alpine half of TryGhost/docker-library-ghost#157 -- interestingly, it's only failing on certain architectures for us (and we've narrowed the reproducer down to simply running
node /usr/local/lib/node_modules/npm/node_modules/uid-number/get-uid-gid.js, which should segfault on affected platforms).franklouwers commentedon Jan 25, 2019
It's not just "platforms", it's more "environments".
Eg on "64bit Intel/amd", I have three systems I tried this on:
The strange thing is: on that DO node where I can trigger the segfault, I can rebuild the image, based on https://raw.githubusercontent.com/nodejs/docker-node/86b9618674b01fc5549f83696a90d5bc21f38af0/8/alpine/Dockerfile (which should be the latest node:8-alpine Dockerfile), and then it doesn't crash !? So it seems to be an incompatibility when building the image...
As this buggers me quite a lot (I am an instructor and one of the courses I teach happen to have a lot of node-alpine docker examples in them), I am more than happy to test things out, help debug etc. Unfortunately, my musl/glibc C powers are not strong enough to suggest an actual solution...
Anything I can do / help / ...?
franklouwers commentedon Jan 25, 2019
btw: I also suggest that we change the title of this issue, as it is not AWS M5-onl
pieterlukasse commentedon Jan 28, 2019
@raulgomis I have the same issue! When running this:
I get the following on Ubuntu:
but get segmentation fault on Amazon Linux:
trevorlinton commentedon Mar 29, 2019
FWIW we're running on an r5.xlarge. r5.large and tried a c5d.large and experiencing the same issue. Finally switched to using m4.large and the problem stopped. I should say this was on the EXACT same AMI from AWS (
amzn-ami-hvm-2018.03.0.20181129-x86_64-gp2 (ami-01e24be29428c15b2)).Some how the kernal must be picking up something from the host hypervisor and a kernel setting may be contributing to why this only occurs on certain systems.
2 remaining items
MateusPD commentedon Oct 2, 2019
I am also having this issue on 10.16.0-alpine. This error started yesterday for me
gja commentedon Oct 15, 2019
We've also been facing this for from node:10.15-alpine, compiling on quay.io since today morning.
Worked around this by adding
npm config set unsafe-perm trueto our build script.amauryaE3156 commentedon Dec 26, 2019
i am also running with this issue from today morning. having below versions:
Node: v8.17.0
npm: 6.13.4
Docker: Docker version 19.03.5, build 633a0ea838
Docker Compose: docker-compose version 1.13.0, build 1719ceb
Python: Python 2.7.17
issue:
Step 13/18 : RUN npm install -g yarn
---> Running in 62643c8ed0ee
Error: could not get uid/gid
[ 'nobody', 0 ]
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 ()
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. (/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 Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
/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)
ERROR: Service 'block-explorer' failed to build: The command '/bin/sh -c npm install -g yarn' returned a non-zero code: 7
pieterlukasse commentedon Dec 26, 2019
Maybe this helps: https://github.com/opentargets/webapp/blob/34f66d7383e6e4459280826133269d440fc3d5f4/Dockerfile
It seems to be working, with node:8 alpine and yarn install steps.
amauryaE3156 commentedon Dec 27, 2019
thank you pieter, i am geeting this issue please give pointer to solve it.
error:
yarn install v1.12.3
info No lockfile found.
[1/5] Validating package.json...
[2/5] Resolving packages...
warning fabric-client > hoek@4.2.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
warning eslint > file-entry-cache > flat-cache > circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
[3/5] Fetching packages...
[4/5] Linking dependencies...
warning "eslint-plugin-jsx-a11y > axobject-query@2.1.1" has incorrect peer dependency "eslint@^5 || ^6".
warning "eslint-plugin-react > eslint-plugin-eslint-plugin@2.1.0" has incorrect peer dependency "eslint@>=5.0.0".
[5/5] Building fresh packages...
success Saved lockfile.
Done in 33.81s.
Removing intermediate container 15509799e850
---> 6fc9a86e87ed
Step 23/42 : COPY . /var/www/
---> 00dac800a3d0
Step 24/42 : RUN yarn run full-install
---> Running in 31afa823f018
yarn run v1.12.3
error Command "full-install" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: Service 'block-explorer' failed to build: The command '/bin/sh -c yarn run full-install' returned a non-zero code: 1
pieterlukasse commentedon Dec 27, 2019
amauryaE3156: maybe check the project I linked. Try to build that one and check what "full-install" means there (maybe it is a custom config?)
add unsafe-perm
Fix frontend build
x-yuri commentedon Feb 24, 2020
Fixed in
nodejs@12.4.0?nschonni commentedon Apr 3, 2020
Closing since Node 8 support ended 4 months ago
yosifkit commentedon May 11, 2020
This is still a problem on node 10.19 and 10.20 (see the last two issues linked here, waveformhealth/virtualvisit-web#1 and docker-library/official-images#7962). One uses the
node:10:20image and the other installs the node package from Alpine. The lastnode:11-alpine(v11.15.0) image also fails, but it does not happen onnode:12.16-alpine(v12.16.3). It would be nice to see a fix applied fornode:10-alpine, but since Alpine isn't really supported by Node itself I can see that it may be a low priority.In case someone wants to go digging to figure out why it works in newer versions (and if that could be applied to 10), here is what I found out:
docker run -it --rm node:version-alpine node -e 'process.setgid(0)'and check the exit code (139)Segmentation fault (core dumped), start an interactiveshand then runnode -e 'process.setgid(0)'c1.large.arm.xdar5.xlarge,r5.large,c5d.large,c5.xlargem5a.xlargem4.largeobjdump -p main):muslstackalso didn't workFROMtonode:10-alpineLD_PRELOADC file work different than the Alpine provided way to change the stack size.x-yuri commentedon May 12, 2020
@yosifkit It somehow resolved with
node@12.4.0. You can try to inspect the changes.upgraded node-alpine docker image to fix uid/gid issue: nodejs/docker…
Update container (#6)