【问题标题】:How to include Webots in a Docker container build?如何在 Docker 容器构建中包含 Webbot?
【发布时间】:2021-05-17 08:30:32
【问题描述】:

我想将 Webbot 添加到我的 Dockerfile 中,但我遇到了问题。我目前的手动安装步骤(来自here)是:

$ # launch my Docker container without Webots
$ wget -qO- https://cyberbotics.com/Cyberbotics.asc | sudo apt-key add -
$ sudo apt update
$ sudo apt install -y software-properties-common
$ sudo apt-add-repository 'deb https://cyberbotics.com/debian/ binary-amd64/'
$ sudo apt update
$ sudo apt-get install webots
$ # now I have a Docker container with Webots

我想将此过程包含在 Docker 容器的构建中。不过,我不能只在Dockerfile 中使用相同的步骤,因为在安装 webbots 时,它会提示一些标准输入响应,询问键盘的原产国。由于 Docker 在构建时不听标准输入,所以我无法回答这些提示。我尝试像这样管道echo 输出,但它不起作用

# Install Webots (a robot simulator)
RUN wget -qO- https://cyberbotics.com/Cyberbotics.asc | sudo apt-key add -
RUN apt-get update && sudo apt-get install -y \
               software-properties-common \
               libxtst6
RUN sudo apt-add-repository 'deb https://cyberbotics.com/debian/ binary-amd64/'
RUN apt-get update && echo 31 1 | sudo apt-get install -y \
               webots  # the echo fills the "keyboard country of origin" prompts

如何将 Webbot 包含在 Docker 容器中?我不想只使用别人的容器(例如cyberbotics/webots-docker),因为我需要在容器中添加其他东西,比如 ROS2。

【问题讨论】:

标签: docker dockerfile webots


【解决方案1】:

编辑:这个答案不正确。 FROM 不是这样工作的,只会使用最后一个 FROM 语句。

原答案:

事实证明它比我预期的要简单。您可以在 Dockerfile 中包含多个 FROM $IMAGE 语句来组合基础镜像。这是一个解释我所做的示例(请注意,所有ARG 语句必须在第一个FROM 语句之前):

ARG BASE_IMAGE_WEBOTS=cyberbotics/webots:R2021a-ubuntu20.04
ARG IMAGE2=other/image:latest

FROM $BASE_IMAGE_WEBOTS AS base
FROM $IMAGE2 AS image2

# other things needed

【讨论】:

    猜你喜欢
    • 2020-03-17
    • 2020-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-12
    • 1970-01-01
    • 2017-02-15
    • 2020-07-21
    相关资源
    最近更新 更多