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

Dockerfile for debian/pve not work, as arguments USER_ID and GROUP_ID reset to 0, and chdir permission issue #37

Open
geyee opened this issue Oct 30, 2024 · 2 comments

Comments

@geyee
Copy link

geyee commented Oct 30, 2024

I am running the command as follows, but I am encountering an issue.

./rails-new myblogs --devcontainer
[+] Building 2.7s (5/6)                                                                                    docker:default
 => [internal] load build definition from Dockerfile                                                                 0.0s
 => => transferring dockerfile: 418B                                                                                 0.0s
 => [internal] load metadata for docker.io/library/ruby:3.3.4                                                        2.5s
 => [internal] load .dockerignore                                                                                    0.0s
 => => transferring context: 2B                                                                                      0.0s
 => CACHED [1/3] FROM docker.io/library/ruby:3.3.4@sha256:d4233f4242ea25346f157709bb8417c615e7478468e2699c8e86a4e1f  0.0s
 => ERROR [2/3] RUN groupadd -g 0 app && useradd -u 0 -g app -m app                                                  0.1s
------                                                                                                                    
 > [2/3] RUN groupadd -g 0 app && useradd -u 0 -g app -m app:
0.133 groupadd: GID '0' already exists
------
Dockerfile:5
--------------------
   3 |     ARG USER_ID=1000
   4 |     ARG GROUP_ID=1000
   5 | >>> RUN groupadd -g $GROUP_ID app && useradd -u $USER_ID -g app -m app
   6 |     USER app
   7 |     ARG RAILS_VERSION
--------------------
ERROR: failed to solve: process "/bin/sh -c groupadd -g $GROUP_ID app && useradd -u $USER_ID -g app -m app" did not complete successfully: exit code: 4
thread 'main' panicked at src/main.rs:41:5:
assertion failed: status.success()
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I cloned the repo, changed USER_ID =1000 to USER_ID1=1001 and GROUP_ID =1000 to GROUP_ID1 =1001 , and then recompiled it. The error dispeared, but with another question.

RUST_BACKTRACE=full  /app/myruby/rails-new/target/debug/rails-new myblogs --devcontainer
[+] Building 2.5s (9/9) FINISHED                                                                                     docker:default
 => [internal] load build definition from Dockerfile                                                                           0.0s
 => => transferring dockerfile: 637B                                                                                           0.0s
 => [internal] load metadata for docker.io/library/ruby:3.3.4                                                                  2.5s
 => [internal] load .dockerignore                                                                                              0.0s
 => => transferring context: 2B                                                                                                0.0s
 => [1/5] FROM docker.io/library/ruby:3.3.4@sha256:d4233f4242ea25346f157709bb8417c615e7478468e2699c8e86a4e1f0156de8            0.0s
 => CACHED [2/5] RUN if [ -n "$user_id" ] || [ -n "1001" ] || [ -n "${USER_ID1}" ];then echo "1"> output.txt;else echo "2"> o  0.0s
 => CACHED [3/5] RUN echo "USER_ID: ${USER_ID1}, $USER_ID1,$GROUP_ID, GROUP_ID: ${GROUP_ID},$UID_1, ${UID_1}"                  0.0s
 => CACHED [4/5] RUN groupadd -g 1001 app && useradd -u 1001 -g app -m app                                                     0.0s
 => CACHED [5/5] RUN if [ -z "7.2.0" ] ; then gem install rails ; else gem install rails -v 7.2.0 ; fi                         0.0s
 => exporting to image                                                                                                         0.0s
 => => exporting layers                                                                                                        0.0s
 => => writing image sha256:1aaa063fa8feddbb7b3dbfeef42e01c10bd43cb8fa89c642d4feebb4ba0ade75                                   0.0s
 => => naming to docker.io/library/rails-new-3.3.4-7.2.0                                                                       0.0s
/usr/local/bundle/gems/railties-7.2.0/lib/rails/app_loader.rb:69:in `chdir': Permission denied @ chdir_path - .. (Errno::EACCES)
        from /usr/local/bundle/gems/railties-7.2.0/lib/rails/app_loader.rb:69:in `block in exec_app'
        from <internal:kernel>:187:in `loop'
        from /usr/local/bundle/gems/railties-7.2.0/lib/rails/app_loader.rb:48:in `exec_app'
        from /usr/local/bundle/gems/railties-7.2.0/lib/rails/cli.rb:7:in `<top (required)>'
        from <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
        from <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
        from /usr/local/bundle/gems/railties-7.2.0/exe/rails:10:in `<top (required)>'
        from /usr/local/bundle/bin/rails:25:in `load'
        from /usr/local/bundle/bin/rails:25:in `<main>'
thread 'main' panicked at src/main.rs:58:5:
assertion failed: status.success()
stack backtrace:
   0:     0x584ae8a8924a - std::backtrace_rs::backtrace::libunwind::trace::h99efb0985cae5d78
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x584ae8a8924a - std::backtrace_rs::backtrace::trace_unsynchronized::he2c1aa63b3f7fad8
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x584ae8a8924a - std::sys::backtrace::_print_fmt::h8a221d40f5e0f88b
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/sys/backtrace.rs:66:9
   3:     0x584ae8a8924a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h304520fd6a30aa07
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/sys/backtrace.rs:39:26
   4:     0x584ae8aa94fb - core::fmt::rt::Argument::fmt::h5da9c218ec984eaf
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/rt.rs:177:76
   5:     0x584ae8aa94fb - core::fmt::write::hf5713710ce10ff22
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/mod.rs:1178:21
   6:     0x584ae8a86c83 - std::io::Write::write_fmt::hda708db57927dacf
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/io/mod.rs:1823:15
   7:     0x584ae8a8a3f2 - std::sys::backtrace::BacktraceLock::print::hbcdbec4d97c91528
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/sys/backtrace.rs:42:9
   8:     0x584ae8a8a3f2 - std::panicking::default_hook::{{closure}}::he1ad87607d0c11c5
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:266:22
   9:     0x584ae8a8a05e - std::panicking::default_hook::h81c8cd2e7c59ee33
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:293:9
  10:     0x584ae8a8abef - std::panicking::rust_panic_with_hook::had2118629c312a4a
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:797:13
  11:     0x584ae8a8a933 - std::panicking::begin_panic_handler::{{closure}}::h7fa5985d111bafa2
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:664:13
  12:     0x584ae8a89729 - std::sys::backtrace::__rust_end_short_backtrace::h704d151dbefa09c5
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/sys/backtrace.rs:170:18
  13:     0x584ae8a8a5f4 - rust_begin_unwind
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:662:5
  14:     0x584ae893b4f3 - core::panicking::panic_fmt::h3eea515d05f7a35e
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panicking.rs:74:14
  15:     0x584ae893b57c - core::panicking::panic::h102d65dbfa674afe
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panicking.rs:148:5
  16:     0x584ae894db10 - rails_new::main::ha06e40f948e3ce4e
                               at /app/myruby/rails-new/src/main.rs:58:5
  17:     0x584ae8943d0b - core::ops::function::FnOnce::call_once::hf5a8570e4403693a
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/ops/function.rs:250:5
  18:     0x584ae894d1de - std::sys::backtrace::__rust_begin_short_backtrace::h94d343f15a821405
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/sys/backtrace.rs:154:18
  19:     0x584ae8947031 - std::rt::lang_start::{{closure}}::h6de1ac629a1f0ec3
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/rt.rs:164:18
  20:     0x584ae8a829f0 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h08ecba131ab90ec4
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/ops/function.rs:284:13
  21:     0x584ae8a829f0 - std::panicking::try::do_call::hf33a59fd8ce953f4
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:554:40
  22:     0x584ae8a829f0 - std::panicking::try::h5005ce80ce949fd8
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:518:19
  23:     0x584ae8a829f0 - std::panic::catch_unwind::hfbae19e2e2c5b7ed
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panic.rs:345:14
  24:     0x584ae8a829f0 - std::rt::lang_start_internal::{{closure}}::ha0331c3690741813
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/rt.rs:143:48
  25:     0x584ae8a829f0 - std::panicking::try::do_call::hcdcbdb616b4d0295
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:554:40
  26:     0x584ae8a829f0 - std::panicking::try::h3f2f1725a07d2256
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:518:19
  27:     0x584ae8a829f0 - std::panic::catch_unwind::h51869e04b56b2dc3
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panic.rs:345:14
  28:     0x584ae8a829f0 - std::rt::lang_start_internal::h4d90db0530245041
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/rt.rs:143:20
  29:     0x584ae894700a - std::rt::lang_start::h881cd0e0195ab378
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/rt.rs:163:17
  30:     0x584ae894dc3e - main
  31:     0x7b6c5edc424a - __libc_start_call_main
                               at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  32:     0x7b6c5edc4305 - __libc_start_main_impl
                               at ./csu/../csu/libc-start.c:360:3
  33:     0x584ae893be41 - _start
  34:                0x0 - <unknown>

OS: Linux pve 6.8.12-1-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-1 (2024-08-05T16:17Z) x86_64 GNU/Linux
Meanwhile, I can work with Dockerfile.unix without known issues.
I don't have much knowledge of Rust, and I'm not skilled at debugging it with LLDB right now.

@rafaelfranca
Copy link
Member

Is your user part of the docker group on debian?

@rafaelfranca
Copy link
Member

Can you also test with the new version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants