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

Doesn't work if docker requries sudo #185

Closed
thejpster opened this issue Mar 16, 2018 · 9 comments
Closed

Doesn't work if docker requries sudo #185

thejpster opened this issue Mar 16, 2018 · 9 comments

Comments

@thejpster
Copy link

The recommended Docker installation on CentOS 7 requires you to execute docker with sudo docker. This, I think, means that cross doesn't work.

$ RUST_BACKTRACE=1 cross build --target x86_64-unknown-linux-musl
thread 'main' panicked at 'Unable to obtain Docker version: Error(Msg("`\"docker\" \"version\" \"--format={{.Server.APIVersion}}\"` failed with exit code: Some(1)"), State { next_error: None, backtrace: Some(stack backtrace:
   0:     0x55b597cad7cc - backtrace::backtrace::trace::h74d343bd243c2bab
   1:     0x55b597cace72 - backtrace::capture::Backtrace::new::h17f522d0ff383054
   2:     0x55b597caca21 - error_chain::make_backtrace::h1048ba2a48c66561
   3:     0x55b597cacad4 - <error_chain::State as core::default::Default>::default::h1268cfe8b9cf1090
   4:     0x55b597c7e165 - <std::process::Command as cross::extensions::CommandExt>::run_and_get_stdout::h685df4650ceb1226
   5:     0x55b597c8add9 - std::sync::once::Once::call_once::{{closure}}::h36356e24bc81478a
   6:     0x55b597cbf7ec - std::sync::once::Once::call_inner::h9d56229e10caf16f
                        at /checkout/src/libstd/sync/once.rs:340
   7:     0x55b597c7f5bd - cross::docker::docker_command::h32c9035ff1cbd5f8
   8:     0x55b597c80236 - cross::docker::run::h7c01dd7b0b2d453a
   9:     0x55b597c8f35b - cross::main::h56de26290afb76a1
  10:     0x55b597c88f42 - std::rt::lang_start::{{closure}}::h47f0a903691df8b2
  11:     0x55b597cc0287 - std::rt::lang_start_internal::{{closure}}::h6ddc513d95d559ac
                        at /checkout/src/libstd/rt.rs:59
                         - std::panicking::try::do_call::h7d33aea9be52481f
                        at /checkout/src/libstd/panicking.rs:480
  12:     0x55b597cde65e - __rust_maybe_catch_panic
                        at /checkout/src/libpanic_unwind/lib.rs:101
  13:     0x55b597cc62f9 - std::panicking::try::h33108b08b6395be5
                        at /checkout/src/libstd/panicking.rs:459
                         - std::panic::catch_unwind::hb0149e8b5a4339ed
                        at /checkout/src/libstd/panic.rs:365
                         - std::rt::lang_start_internal::h16c0c37ef62d8e5a
                        at /checkout/src/libstd/rt.rs:58
  14:     0x55b597c90723 - main
  15:     0x7f10dfc8ec04 - __libc_start_main
  16:     0x55b597c7b649 - <unknown>
  17:                0x0 - <unknown>) })', /checkout/src/libcore/result.rs:916:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at /checkout/src/libstd/sys_common/backtrace.rs:68
             at /checkout/src/libstd/sys_common/backtrace.rs:57
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:397
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:577
   5: std::panicking::begin_panic
             at /checkout/src/libstd/panicking.rs:538
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:522
   7: rust_begin_unwind
             at /checkout/src/libstd/panicking.rs:498
   8: core::panicking::panic_fmt
             at /checkout/src/libcore/panicking.rs:71
   9: core::result::unwrap_failed
  10: std::sync::once::Once::call_once::{{closure}}
  11: std::sync::once::Once::call_inner
             at /checkout/src/libstd/sync/once.rs:340
  12: cross::docker::docker_command
  13: cross::docker::run
  14: cross::main
  15: std::rt::lang_start::{{closure}}
  16: std::panicking::try::do_call
             at /checkout/src/libstd/rt.rs:59
             at /checkout/src/libstd/panicking.rs:480
  17: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:101
  18: std::rt::lang_start_internal
             at /checkout/src/libstd/panicking.rs:459
             at /checkout/src/libstd/panic.rs:365
             at /checkout/src/libstd/rt.rs:58
  19: main
  20: __libc_start_main
  21: <unknown>
@jamesmunns
Copy link
Contributor

Hey @thejpster, I think this is a docs problem. Since cross relies on docker to be accessible, we need to have a section in the docs to cover how to check if you are ready to use cross.

If you have any other tricks in mind, let me know!

@thejpster
Copy link
Author

Maybe check an env var and call "sudo docker" instead of "docker"? CROSS_USE_SUDO perhaps?

@gnzlbg
Copy link
Contributor

gnzlbg commented May 2, 2018

@thejpster what do we do about the user then having to input the sudo password on each docker invocation?

@thejpster
Copy link
Author

Yeah, that starts to become a mess. Fabric, for example, reads the password once and passes it to every sudo invocation on stdin.
In the Fedora case, the recommendation is to allow passwordless sudo docker and so it's not an issue.

@oblitum
Copy link

oblitum commented Oct 14, 2019

related: #298

tldr: podman support would be great.

@janvier-vip
Copy link

Resolved. Adds yourself to the docker group to execute docker command without root privilege.

@oblitum
Copy link

oblitum commented Jan 8, 2020

@janvier-ninja that's not a solution, as the docker group is high privileged.

@Emerentius
Copy link

I'm not willing to make docker accessible without password because of the security risk, so I worked around this with this command
sudo env "PATH=$PATH" "RUSTUP_HOME=$(echo ~/.rustup)" cross …

@Alexhuszagh
Copy link
Contributor

Alexhuszagh commented Jul 2, 2022

We support other container engines now (notably, Podman, which doesn't run as root) and rootless Docker, so this in no longer an issue. This is a design choice of Docker, not an issue in cross itself.

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

No branches or pull requests

7 participants