【问题标题】:Docker: Cargo.toml not found泊坞窗:未找到 Cargo.toml
【发布时间】:2017-02-02 09:21:53
【问题描述】:

我有一个具有以下结构的 Cargo 项目:

experiment
|
|- Dockerfile
|- Cargo.toml
|- src/
|-- main.rs

我的 Dockerfile 的内容是 (source):

FROM scorpil/rust:1.10

RUN mkdir -p /rust/app
WORKDIR /rust/app

ONBUILD COPY . /rust/app
OBUILD CMD ls -a /source
ONBUILD RUN cargo build --release

CMD cargo run --release

我已经成功构建了映像,但是当我尝试在本地计算机上运行它时,出现以下错误:

docker run -i -d -p 8080:80 --name rust_hello_world menawi/rust_hello_world

517a8772100cbd6fd388df1f3767175113ce2dbad93d144976b59d63d4809146

docker ps -a

CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS                        PORTS               NAMES
517a8772100c        menawi/rust_hello_world   "/bin/sh -c 'cargo ru"   17 seconds ago      Exited (101) 11 seconds ago                       rust_hello_world

docker 记录 rust_hello_world

error: could not find `Cargo.toml` in `/rust/app` or any parent directory

为什么会出现此错误?有什么方法可以查看哪些文件被复制到 /rust/app 文件夹中?

【问题讨论】:

    标签: docker rust-cargo


    【解决方案1】:

    您可以运行容器并将CMD 替换为bash 之类的

    docker run -i -t -p 8080:80 --name rust_hello_world menawi/rust_hello_world bash

    比你在容器的 bash 中,你可以打印文件夹中的文件列表

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-12
      • 2019-09-19
      • 2021-11-05
      • 2018-12-20
      • 2019-06-28
      • 2016-10-20
      • 1970-01-01
      相关资源
      最近更新 更多