CentOS
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
Ubuntu
ENV TZ=Asia/Shanghai
RUN echo $TZ > /etc/timezone && \
dpkg-reconfigure -f noninteractive tzdata
resource 与 Dockerfile 为同级目录,id_rsa 为本机的私钥
CentOs
# COPY credentials on build
COPY resource/id_rsa /root/.ssh/id_rsa
RUN chmod 600 /root/.ssh/id_rsa && \
echo 'StrictHostKeyChecking no' >> /etc/ssh/ssh_config
# Remove SSH keys
RUN rm -rf /root/.ssh/
Ubuntu
# COPY credentials on build
COPY resource/id_rsa /root/.ssh/id_rsa
RUN chmod 600 /root/.ssh/id_rsa && \
echo "StrictHostKeyChecking no\nUserKnownHostsFile /dev/null" >> /root/.ssh/config
# Remove SSH keys
RUN rm -rf /root/.ssh/