【问题标题】:Installing SSH on a Docker image在 Docker 映像上安装 SSH
【发布时间】:2020-10-20 13:05:50
【问题描述】:

我正在尝试使用以下命令在 docker 映像上安装 SSH:

RUN APT INSTALL -Y SSH

这似乎会在映像上安装 SSH,但是如果我通过隧道进入正在运行的容器并手动运行命令,则会提示我设置区域和时区。是否可以将这些选项传递给 install SSH 命令? 我可以手动安装 SSH 的容器可以使用以下命令启动:

docker container run -it --rm -p 22:22 ubuntu:latest

我的 Docker 镜像如下:

FROM ubuntu:latest
RUN apt update
apt -y install ssh

谢谢

【问题讨论】:

标签: docker ubuntu ssh dockerfile apt


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-03
    • 1970-01-01
    • 1970-01-01
    • 2016-09-08
    • 2016-07-22
    • 2020-11-08
    相关资源
    最近更新 更多