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

Getting panicked at 'error: NoAvailablePorts in alpine container. #267

Open
natarajanmca11 opened this issue Aug 29, 2021 · 4 comments
Open

Comments

@natarajanmca11
Copy link

Getting panicked at 'error: NoAvailablePorts in alpine container.

Error Stack

thread 'actix-rt|system:0|arbiter:0' panicked at 'error: NoAvailablePorts

   0: failure::backtrace::internal::InternalBacktrace::new
   1: failure::backtrace::Backtrace::new
   2: headless_chrome::browser::process::Process::new
   3: headless_chrome::browser::Browser::new
   4: apis::business::pdf::browser
   5: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   6: <actix_web::handler::HandlerServiceFuture<F,T,R> as core::future::future::Future>::poll
   7: <core::pin::Pin<P> as core::future::future::Future>::poll
   8: <core::pin::Pin<P> as core::future::future::Future>::poll
   9: <core::pin::Pin<P> as core::future::future::Future>::poll
  10: <actix_web::middleware::err_handlers::ErrorHandlersFuture<Fut,B> as core::future::future::Future>::poll
  11: <actix_web::middleware::logger::LoggerResponse<S,B> as core::future::future::Future>::poll
  12: actix_http::h1::dispatcher::InnerDispatcher<T,S,B,X,U>::poll_response
  13: <actix_http::h1::dispatcher::Dispatcher<T,S,B,X,U> as core::future::future::Future>::poll
  14: <actix_http::service::HttpServiceHandlerResponse<T,S,B,X,U> as core::future::future::Future>::poll
  15: <actix_service::and_then::AndThenServiceResponse<A,B,Req> as core::future::future::Future>::poll
  16: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  17: tokio::runtime::task::core::CoreStage<T>::poll
  18: tokio::runtime::task::harness::Harness<T,S>::poll
  19: std::thread::local::LocalKey<T>::with
  20: tokio::task::local::LocalSet::tick
  21: tokio::macros::scoped_tls::ScopedKey<T>::set
  22: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  23: tokio::macros::scoped_tls::ScopedKey<T>::set
  24: tokio::runtime::Runtime::block_on
  25: std::sys_common::backtrace::__rust_begin_short_backtrace
  26: core::ops::function::FnOnce::call_once{{vtable.shim}}
  27: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/alloc/src/boxed.rs:1521:9
      <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/alloc/src/boxed.rs:1521:9
      std::sys::unix::thread::Thread::new::thread_start
             at rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys/unix/thread.rs:71:17
', src/business/pdf.rs:23:54
stack backtrace:
   0: rust_begin_unwind
             at ./rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at ./rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/panicking.rs:92:14
   2: core::option::expect_none_failed
             at ./rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/option.rs:1300:5
   3: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   4: <actix_web::handler::HandlerServiceFuture<F,T,R> as core::future::future::Future>::poll
   5: <core::pin::Pin<P> as core::future::future::Future>::poll
   6: <core::pin::Pin<P> as core::future::future::Future>::poll
   7: <core::pin::Pin<P> as core::future::future::Future>::poll
   8: <actix_web::middleware::err_handlers::ErrorHandlersFuture<Fut,B> as core::future::future::Future>::poll
   9: <actix_web::middleware::logger::LoggerResponse<S,B> as core::future::future::Future>::poll
  10: actix_http::h1::dispatcher::InnerDispatcher<T,S,B,X,U>::poll_response
  11: <actix_http::h1::dispatcher::Dispatcher<T,S,B,X,U> as core::future::future::Future>::poll
  12: <actix_http::service::HttpServiceHandlerResponse<T,S,B,X,U> as core::future::future::Future>::poll
  13: <actix_service::and_then::AndThenServiceResponse<A,B,Req> as core::future::future::Future>::poll
  14: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  15: tokio::runtime::task::core::CoreStage<T>::poll
  16: tokio::runtime::task::harness::Harness<T,S>::poll
  17: std::thread::local::LocalKey<T>::with
  18: tokio::task::local::LocalSet::tick
  19: tokio::macros::scoped_tls::ScopedKey<T>::set
  20: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  21: tokio::macros::scoped_tls::ScopedKey<T>::set
  22: tokio::runtime::Runtime::block_on
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
/usr/local/bin/html/1630207912834.html
thread 'actix-rt|system:0|arbiter:3' panicked at 'error: NoAvailablePorts

   0: failure::backtrace::internal::InternalBacktrace::new
   1: failure::backtrace::Backtrace::new
   2: headless_chrome::browser::process::Process::new
   3: headless_chrome::browser::Browser::new
   4: apis::business::pdf::browser
   5: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   6: <actix_web::handler::HandlerServiceFuture<F,T,R> as core::future::future::Future>::poll
   7: <core::pin::Pin<P> as core::future::future::Future>::poll
   8: <core::pin::Pin<P> as core::future::future::Future>::poll
   9: <core::pin::Pin<P> as core::future::future::Future>::poll
  10: <actix_web::middleware::err_handlers::ErrorHandlersFuture<Fut,B> as core::future::future::Future>::poll
  11: <actix_web::middleware::logger::LoggerResponse<S,B> as core::future::future::Future>::poll
  12: actix_http::h1::dispatcher::InnerDispatcher<T,S,B,X,U>::poll_response
  13: <actix_http::h1::dispatcher::Dispatcher<T,S,B,X,U> as core::future::future::Future>::poll
  14: <actix_http::service::HttpServiceHandlerResponse<T,S,B,X,U> as core::future::future::Future>::poll
  15: <actix_service::and_then::AndThenServiceResponse<A,B,Req> as core::future::future::Future>::poll
  16: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  17: tokio::runtime::task::core::CoreStage<T>::poll
  18: tokio::runtime::task::harness::Harness<T,S>::poll
  19: std::thread::local::LocalKey<T>::with
  20: tokio::task::local::LocalSet::tick
  21: tokio::macros::scoped_tls::ScopedKey<T>::set
  22: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  23: tokio::macros::scoped_tls::ScopedKey<T>::set
  24: tokio::runtime::Runtime::block_on
  25: std::sys_common::backtrace::__rust_begin_short_backtrace
  26: core::ops::function::FnOnce::call_once{{vtable.shim}}
  27: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/alloc/src/boxed.rs:1521:9
      <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/alloc/src/boxed.rs:1521:9
      std::sys::unix::thread::Thread::new::thread_start
             at rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/sys/unix/thread.rs:71:17
', src/business/pdf.rs:23:54
stack backtrace:
   0: rust_begin_unwind
             at ./rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at ./rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/panicking.rs:92:14
   2: core::option::expect_none_failed
             at ./rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/option.rs:1300:5
   3: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   4: <actix_web::handler::HandlerServiceFuture<F,T,R> as core::future::future::Future>::poll
   5: <core::pin::Pin<P> as core::future::future::Future>::poll
   6: <core::pin::Pin<P> as core::future::future::Future>::poll
   7: <core::pin::Pin<P> as core::future::future::Future>::poll
   8: <actix_web::middleware::err_handlers::ErrorHandlersFuture<Fut,B> as core::future::future::Future>::poll
   9: <actix_web::middleware::logger::LoggerResponse<S,B> as core::future::future::Future>::poll
  10: actix_http::h1::dispatcher::InnerDispatcher<T,S,B,X,U>::poll_response
  11: <actix_http::h1::dispatcher::Dispatcher<T,S,B,X,U> as core::future::future::Future>::poll
  12: <actix_http::service::HttpServiceHandlerResponse<T,S,B,X,U> as core::future::future::Future>::poll
  13: <actix_service::and_then::AndThenServiceResponse<A,B,Req> as core::future::future::Future>::poll
  14: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  15: tokio::runtime::task::core::CoreStage<T>::poll
  16: tokio::runtime::task::harness::Harness<T,S>::poll
  17: std::thread::local::LocalKey<T>::with
  18: tokio::task::local::LocalSet::tick
  19: tokio::macros::scoped_tls::ScopedKey<T>::set
  20: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  21: tokio::macros::scoped_tls::ScopedKey<T>::set
  22: tokio::runtime::Runtime::block_on
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Docker file reference

ARG BASE_IMAGE=ekidd/rust-musl-builder:latest

# Our first FROM statement declares the build environment.
FROM ${BASE_IMAGE} AS builder

# Add our source code.
ADD . ./

# Fix permissions on source code.
RUN sudo chown -R rust:rust /home/rust

# Build our application.
RUN cargo build --release

FROM alpine:latest
# RUN apk --no-cache add ca-certificates

# Installs latest Chromium (latest) package.
RUN apk update && apk upgrade && \
    echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories && \
    echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories && \
    apk add --no-cache \
    chromium@edge \
    nss@edge \
    freetype@edge \
    harfbuzz@edge \
    ttf-freefont@edge

RUN addgroup -S chrome && adduser -S -g chrome chrome \
    && mkdir -p /home/chrome/Downloads \
    && chown -R chrome:chrome /home/chrome \
    && chown -R chrome:chrome /usr/local/bin

USER chrome

EXPOSE 3000
EXPOSE 8000-9000

COPY --from=builder \
    /home/rust/src/target/x86_64-unknown-linux-musl/release/apis \
    /usr/local/bin/

CMD /usr/local/bin/apis

Makefile

container:
	docker build -t apis .

container-run:
	docker run -it -e SERVER=0.0.0.0:3000 -p 3000:3000 -p 8000-9000:8000-9000 apis
@nebnes
Copy link
Contributor

nebnes commented Oct 18, 2021

Maybe be you are running chrome with "sandbox"
You can try without it :

let options = LaunchOptionsBuilder::default()
        .window_size(Some((1800, 1500)))
        .sandbox(false)
        .build()
        .unwrap();

@amaury1093
Copy link

Same, also getting error There are no available ports between 8000 and 9000 for debugging in alpine container. I tried both with and without sandbox.

@fcoury
Copy link
Contributor

fcoury commented Aug 1, 2023

Not sure if too late, but wanted to update this issue with my findings. This error occurs when you run as root with no sandbox. I opened a PR with the fix:

#406

@MrFoxPro
Copy link

This is still happening on some windows machines as well.

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

5 participants