在Docker镜像中安装SSH

3

我正在尝试使用以下命令在 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

谢谢


https://docs.docker.com/engine/examples/running_ssh_service/ - Exploding Kitten
1个回答

3

你可以使用 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 ...

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接