Dockerfile技巧

换镜像源

Ubuntu

RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list

Alpine

RUN sed -i 's/http:\/\/dl-cdn.alpinelinux.org/https:\/\/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories

移除软件包缓存

Ubuntu

RUN rm -vrf /var/lib/apt/lists/*

Alpine

RUN rm -vrf /var/cache/apk/* && \
rm -vrf /var/lib/apk/* && \
rm -vrf /etc/apk/cache/*

常用软件的安装使用方式

ping

apt install -yqq inetutils-ping

vnc for firefox

RUN apt update && apt install x11vnc xufb

RUN mkdir /.vnc

RUN x11vnc -storepasswd pass ~/.vnc/passwd

RUN bash -c 'echo "firefox" >> /.bashrc

EXPOSE 5900

CMD ["x11vnc", "-forever", "-usepw", "-create"]

ssh取消pam登陆

RUN sed -ri 's/session required pam_loginuid.so/#session required pam_loginuid.so/g' /etc/pam.d/sshd

debian的非交互式操作

ENV DEBIAN_FRONTEND noninteractive

apache httpd

RUN exec apache2 -D FOREGROUND

以新用户身份运行

RUN adduser --disabled-login user

RUN su user -c 'command'

上一篇:前端基本知识(三):JS的闭包理解(第一个思考题有错误,已修改)


下一篇:【转载】Google Analytics 使用图文全攻略