docker - 如何在 Docker 容器中使用 Cargo 安装 mdbook?
问题描述
我正在尝试构建一个包含 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 的版本仍然是 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
推荐阅读
- postgresql - 在 postgres 中自动生成许多字母数字字符串并将它们作为数组添加到 JSONB 以插入
- java - Apache 使用 modjk 作为 WordPress 和 Tomcat 的代理
- node.js - 如何向我的网络应用程序的用户显示不同的内容?MERN 堆栈
- python - Python:如何从开始、停止、步进循环的迭代中调用中断后的位置
- css - 多行 FormInput 元素离开屏幕
- jquery - 为什么我按下按钮时所有信息都消失了
- php - 在使用 Jalali 波斯日期的字符串上调用成员函数 diff()
- google-apps-script - 向公式添加参数
- php - 将变量解析为类对象
- javascript - Serverless 不创建 SQS 事件