Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodejs inside docker image using dockerTools.buildImage cannot start in NixOS (but starts in Ubuntu) #170279

Closed
CMCDragonkai opened this issue Apr 25, 2022 · 6 comments
Labels
0.kind: bug Something is broken 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: docker tools 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: nodejs

Comments

@CMCDragonkai
Copy link
Member

CMCDragonkai commented Apr 25, 2022

Describe the bug

When using dockerTools.buildImage with just nodejs as the only contents, it is not possible to run the /bin/node inside the container in NixOS. But it does work in Ubuntu 22.04.

Steps To Reproduce

Steps to reproduce the behavior:

    dockerTools.buildImage {
      name = "nodejs";
      contents = [ nodejs ];
      keepContentsDirlinks = true;
      extraCommands = ''
        mkdir -m 1777 tmp
      '';
    };

Build that with nix-build or nix repl, and then load it and run:

loaded="$(docker load --input "$(nix-build ./default.nix)")"
image="$(cut -d' ' -f3 <<< "$loaded")"
docker run -it "$image" /bin/node

Results in:

/bin/node[1]: ../src/node_platform.cc:61:std::unique_ptr<long unsigned int> node::WorkerThreadsTaskRunner::DelayedTaskScheduler::Start(): Assertion `(0) == (uv_thread_create(t.get(), start_thread, this))' failed.
 1: 0xa64dd8 node::Abort() [/bin/node]
 2: 0xa64e67  [/bin/node]
 3: 0xae5f75 node::WorkerThreadsTaskRunner::WorkerThreadsTaskRunner(int) [/bin/node]
 4: 0xae60a2 node::NodePlatform::NodePlatform(int, v8::TracingController*) [/bin/node]
 5: 0xa24d2f node::V8Platform::Initialize(int) [/bin/node]
 6: 0xa2304b node::InitializeOncePerProcess(int, char**, node::InitializationSettingsFlags, node::ProcessFlags::Flags) [/bin/node]
 7: 0xa231d9 node::InitializeOncePerProcess(int, char**) [/bin/node]
 8: 0xa23238 node::Start(int, char**) [/bin/node]
 9: 0x7f1c2eaf91d7  [/nix/store/ayrsyv7npr0lcbann4k9lxr19x813f0z-glibc-2.34-115/lib/libc.so.6]
10: 0x7f1c2eaf9297 __libc_start_main [/nix/store/ayrsyv7npr0lcbann4k9lxr19x813f0z-glibc-2.34-115/lib/libc.so.6]
11: 0x989ce1 _start [/bin/node]

Expected behavior

It should just run the node repl.

Additional context

Add any other context about the problem here.

Metadata

I'm pinned on a5774e7 as the nixpkgs commit revision.

Running on NixOS

»» ~
 ♖ nix-shell -p nix-info --run "nix-info -m"                                                      pts/3 1:41:14
 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.106, Matrix Vostro 5402 1, noversion`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.16`
 - nixpkgs: `/etc/nixpkgs`

And my NixOS nixpkgs revision is d89f18a

@CMCDragonkai CMCDragonkai added the 0.kind: bug Something is broken label Apr 25, 2022
@CMCDragonkai
Copy link
Member Author

Googling leads to links that say that this is due to some ulimits problem. Not sure why nixos docker containers are having this problem.

@CMCDragonkai
Copy link
Member Author

I've done some further testing.

I've built the same image using the above expression.

If I try to run it on NixOS docker, I get the above error.

If I put it into an Ubuntu 22.04 LTS virtual machine Linux cmcdragonkai-VirtualBox 5.15.0-27-generic #28-Ubuntu SMP Thu Apr 14 04:55:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux, it ends up running fine.

image

I believe this is a NixOS problem. My docker configuration on NixOS is simple:

*     virtualisation.docker = {
        enable = true;
        enableNvidia = true;
        storageDriver = "zfs";
*       extraOptions = "--bip 172.18.0.1/16";
      };

@CMCDragonkai
Copy link
Member Author

If anybody else wants to confirm, you can build the docker image from here: https://github.com/MatrixAI/TypeScript-Demo-Lib.

nix-build ./release.nix --attr docker

Note that the repo is a more sophisticated version of the above expression. I simplified the above expression to make the issue report easier.

@CMCDragonkai CMCDragonkai changed the title Nodejs inside docker image using dockerTools.buildImage cannot start Nodejs inside docker image using dockerTools.buildImage cannot start in NixOS (but starts in Ubuntu) Apr 26, 2022
@roberth roberth added the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Apr 26, 2022
@CMCDragonkai
Copy link
Member Author

CMCDragonkai commented May 10, 2022

Look like this docker bug affects Ubuntu 22.04 too, see Tzahi12345/YoutubeDL-Material#610. However that could be a CI/CD option.

@CMCDragonkai
Copy link
Member Author

It's possible that some default docker configuration has changed recently.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 12, 2022
@CMCDragonkai
Copy link
Member Author

Doesn't appear to happen anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: docker tools 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: nodejs
Projects
None yet
Development

No branches or pull requests

3 participants