【问题标题】:How to convert these few dockerfile commands into linux bash commands如何将这几个 dockerfile 命令转换成 linux bash 命令
【发布时间】:2020-04-04 07:17:31
【问题描述】:

我需要在我的 docker 容器中配置 SSH 服务以进行远程调试 我阅读了 Dockerizing an SSH Service 并获取了 dockerfile。但是由于种种原因,我需要进入容器使用bash命令行配置SSH。

有4个dockerfile命令我不知道怎么转成bash 命令,请帮助我。

ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
EXPOSE 22 7777
CMD ["/usr/sbin/sshd", "-D"]

【问题讨论】:

  • 通常您不会在容器中安装 ssh 守护程序(端口映射、用户身份,尤其是涉及的所有凭据非常很难正确处理,并且在一个容器中运行多个进程会增加很多复杂性)或在交互式 shell 中执行大量工作;我会尝试重新审视你的方法。

标签: bash docker


【解决方案1】:

你可以试试这个:

# set Environmentvariable
export NOTVISIBLE="in users profile"

# append 'export VISIBLE=now' to /etc/profile
echo "export VISIBLE=now" >> /etc/profile

# start ssh daemon in foreground
/usr/sbin/sshd -D

EXPOSE 从容器派生端口 22 和 7777,不能使用 bash 脚本进行设置。这必须在创建容器时完成。

【讨论】:

  • 非常感谢。这里还有两个 docker 命令。你也可以转换它们吗?添加 。 /code WORKDIR /code
  • 这两个命令都是容器构造的一部分。第一个复制当前目录“。”中的所有内容。到容器中的/code。第二个定义工作目录。在容器中,它可以用cd /code“模拟”。
猜你喜欢
  • 2021-07-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-06
  • 1970-01-01
  • 2011-05-24
  • 2020-01-03
  • 2021-03-28
相关资源
最近更新 更多