here-documents
换源
COPY <<EOF /etc/apt/sources.list.d/ubuntu.sources
Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu
Suites: noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
EOF
RUN
RUN <<EOT bash
set -ex
apt-get update
apt-get install -y vim
EOT
https://docs.docker.com/reference/dockerfile/#here-documents
apt install
RUN apt-get update && \
apt-get install -y wget --no-install-recommends && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean
无人值守
替代文件内容
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \

Comments NOTHING