Home > Blockchain >  Permission denied error when running docker image with rust binary
Permission denied error when running docker image with rust binary

Time:12-14

I am getting permission denied when trying to run a small rust cli app via a docker container. I can build the image fine, but when I try to run it I get:

docker: Error response from daemon: OCI runtime create failed: 
container_linux.go:380: 
starting container process caused: exec: "./async-scraper": permission denied: 
unknown.

Dockerfile

FROM clux/muslrust:1.56.1-stable as builder
WORKDIR /volume
COPY . .
RUN cargo build --release

FROM alpine
COPY --from=builder /volume/target/x86_64-unknown-linux-musl/release ./async-scraper
RUN chmod  x ./async-scraper
ENTRYPOINT [ "./async-scraper","$@"]

Run cmd

sudo docker run --rm -it paul-k/web_scraper:latest - 
https://example-url-arg/

Cargo.toml

[package]
name = "async_web_scraper"
version = "0.1.0"
edition = "2018"

[[bin]]
name = "rat"
path = "src/main.rs"

[lib]
name = "async_scraper"

[dependencies]
select = "0.6.0-alpha.1"
reqwest = { version = "0.11.6", features = ["json"] }
tokio = { version = "1", features = ["full"] }
futures = "0.3.1"
lazy_static = "1.4.0"
url = "2.2.2"
error-chain = "0.12.4"
async-trait = "0.1.51"
simple-error = "0.1.9"
anyhow = "1.0"
log = "0.4.14"
env_logger = "0.9.0"
thiserror = "1.0.30"

[dev-dependencies]
httpmock = "0.6"
tokio-test = "*"

CodePudding user response:

You are trying to execute a directory "/volume/target/x86_64-unknown-linux-musl/release". I advise you use cargo install:

RUN cargo install --path . --root /volume

# ...

COPY --from=builder /volume/bin/rat /volume/rat
WORKDIR /volume
ENTRYPOINT [ "./rat","$@"]
  • Related