rust-lang / docker-rust

The official Docker images for Rust
441 stars 90 forks source link

docker build hangs forever on Cargo install command #34

Closed bgbahoue closed 6 years ago

bgbahoue commented 6 years ago

I am trying to build a Docker image using Rust official image but it hangs forever on the cargo install command while it works fine when I run cargo install from a terminal.

I have seen a few old issues on this but none of the solutions that were listed then are working.

Anything I can do to solve this?

Output from docker install -t <myapp> . command

Sending build context to Docker daemon 1.73MB Step 1/5 : FROM rust:1.23.0 ---> c694858c0c3c Step 2/5 : WORKDIR /usr/src/ ---> Using cache ---> 7af2b1e4af1f Step 3/5 : COPY . . ---> Using cache ---> a61f33cd9dd3 Step 4/5 : RUN cargo install ---> Running in c9c573188020 Installing v0.1.0 (file:///usr/src/) Updating registry https://github.com/rust-lang/crates.io-index

sfackler commented 6 years ago

Are you sure "forever" actually means forever? The first time you build cargo has to clone the index which can take a bit if you're on slow internet. If you run the container interactively and build manually you can see a progress bar.

bgbahoue commented 6 years ago

You're right it "just" took a super long time (>2h)

Is there a way to accelerate this? How can I get that progress bar you are mentioning?

sfackler commented 6 years ago

You could have a base image that's downloaded a copy of the index potentially. You can see the progress bar if you run cargo build manually inside of docker run -it --rm ... rust:1.29.0 bash

shaoxp commented 3 years ago

Are you sure "forever" actually means forever? The first time you build cargo has to clone the index which can take a bit if you're on slow internet. If you run the container interactively and build manually you can see a progress bar.

i think from docker build point of view, every time is the first time, it will always be slow. right?