【发布时间】:2022-12-31 19:51:18
【问题描述】:
Azure 文档提供了有关如何在自定义容器中 enable SSH 的说明。他们建议在我的 Dockerfile 中添加这些命令:
# Install OpenSSH and set the password for root to "Docker!". In this example, "apk add" is the install instruction for an Alpine Linux-based image.
RUN apk add openssh \
&& echo "root:Docker!" | chpasswd
# Copy the sshd_config file to the /etc/ssh/ directory
COPY sshd_config /etc/ssh/
# Copy and configure the ssh_setup file
RUN mkdir -p /tmp
COPY ssh_setup.sh /tmp
RUN chmod +x /tmp/ssh_setup.sh \
&& (sleep 1;/tmp/ssh_setup.sh 2>&1 > /dev/null)
# Open port 2222 for SSH access
EXPOSE 80 2222
为什么chmod +x命令后面有一个sleep 1?我知道它没有害处,但我真的很想知道为什么它在那里。
【问题讨论】:
-
这与编程有什么关系? --- 为什么不问 azure 支持?
-
@Turing85 那将是另一种选择。我在这里问是因为我怀疑可能有一些我不知道的关于 bash/shell 脚本的东西可以解释
sleep命令。但是,这可能是 Azure 特有的东西,或者可能完全没有必要(即非最佳示例)。我只是不知道它是什么,所以我从这里开始。 -
shell 没有任何要求在那里睡觉的东西。
标签: azure docker dockerfile azure-web-app-service