1

I want to add Webots to my Dockerfile, but I'm running into an issue. My current manual installation steps (from here) are:

$ # 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

I want to include this process in the build of the Docker container. I can't just use the same steps in Dockerfile though, because while webots is installing, it prompts for some stdin responses asking for the keyboard's country of origin. Since Docker doesn't listen to stdin while building, I have no way to answer these prompts. I tried piping echo output like so, but it doesn't work:

# 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

How can I get Webots included in the Docker container? I don't want to just use someone else's container (e.g. cyberbotics/webots-docker), since I need to add other things to the container, like ROS2.

Drake P
  • 174
  • 9
  • 1
    why don't you just copy and edit https://github.com/cyberbotics/webots-docker/blob/master/Dockerfile? – Yohanes Gultom Feb 14 '21 at 01:06
  • Does setting `DEBIAN_FRONTEND=noninteractive` as described in [Is it possible to answer dialog questions when installing under docker?](https://stackoverflow.com/questions/22466255/is-it-possible-to-answer-dialog-questions-when-installing-under-docker) help? (You don't need `sudo` here at all; the Dockerfile should run as root by default.) – David Maze Feb 14 '21 at 01:47

1 Answers1

0

Edit: this answer is incorrect. FROM doesn't work like this, and only the last FROM statement will be utilized.

Original answer:

It turns out to be simpler than I expected. You can include more than one FROM $IMAGE statement in a Dockerfile to combine base images. Here's a sample explaining what I did (note that all the ARG statements must come before the first FROM statement):

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
Drake P
  • 174
  • 9