【问题标题】:How do I install mdbook using Cargo inside a Docker container?如何在 Docker 容器中使用 Cargo 安装 mdbook?
【发布时间】:2019-04-03 23:53:36
【问题描述】:

我正在尝试构建一个包含 Rust 和 mdbook 的 Docker 容器。我已经尝试了很多变化

FROM rust:latest
RUN cargo install mdbook

包括指定确切的版本。例如,这些也不起作用

RUN cargo install --git https://github.com/rust-lang-nursery/mdBook.git mdbook

RUN cargo install mdbook --vers "^0.1.0"

安装到编译lazycell v1.2.0 时出现问题:

Compiling lazycell v1.2.0
error: `<core::cell::UnsafeCell<T>>::new` is not yet stable as a const fn
   --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/lazycell-1.2.0/src/lib.rs:233:16
    |
233 |         inner: UnsafeCell::new(None),
    |                ^^^^^^^^^^^^^^^^^^^^^
    |
    = help: in Nightly builds, add `#![feature(const_unsafe_cell_new)]` to the crate attributes to enable

【问题讨论】:

    标签: docker rust rust-cargo


    【解决方案1】:

    您可以构建自己的容器,而不是使用 Docker 中的 Rust 容器。 Rust 的版本仍然是 1.30(与 FROM rust:latest 一样),但由于某种原因,此过程正确地获取了所有依赖项。

    FROM ubuntu:latest
    FROM gcc:latest
    
    RUN apt-get update && \
        apt-get install -y curl
    
    WORKDIR /tmp
    
    RUN curl https://sh.rustup.rs -sSf > rustup.sh
    RUN chmod 755 rustup.sh
    RUN ./rustup.sh -y
    RUN rm /tmp/rustup.sh
    
    RUN ~/.cargo/bin/cargo install mdbook
    

    【讨论】:

      猜你喜欢
      • 2017-11-11
      • 2021-09-08
      • 1970-01-01
      • 1970-01-01
      • 2022-07-13
      • 1970-01-01
      • 1970-01-01
      • 2020-01-17
      • 2019-06-03
      相关资源
      最近更新 更多