我正在尝试使用以下命令在 docker 镜像上安装 SSH:
RUN APT INSTALL -Y SSH
这似乎在图像上安装了 SSH,但是如果我隧道进入正在运行的容器并手动运行命令,我会收到设置区域和时区的提示。是否可以将这些选项传递给安装 SSH 命令? 我能够手动安装 SSH 的容器可以使用以下命令启动:
docker container run -it --rm -p 22:22 ubuntu:latest
我的Docker镜像如下:
FROM ubuntu:latest
RUN apt update
apt -y install ssh
谢谢
最佳答案
您可以使用 DEBIAN_FRONTEND
来禁用与用户的交互 (DEBIAN_FRONTEND):
noninteractive
This is the anti-frontend. It never interacts with you at all,
and makes the default answers be used for all questions. It
might mail error messages to root, but that's it; otherwise it
is completely silent and unobtrusive, a perfect frontend for
automatic installs. If you are using this front-end, and require
non-default answers to questions, you will need to preseed the
debconf database; see the section below on Unattended Package
Installation for more details.
像这样:
FROM ubuntu:latest
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/London
RUN apt update && \
apt -y install ...
关于docker - 在 Docker 镜像上安装 SSH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62653871/