blogimage-docker-compose_shrink

Change System date time

inside the container

alpine

apk add tzdata
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

Dokerfile

要根据系统版本来设置,把在容器里输的命令复制到Dockerfile里RUN即可

Change sources.list

Dockerfile

Debian (php5.6-apache etc.)

RUN echo "deb http://mirrors.ustc.edu.cn/debian/ stretch main non-free contrib" > /etc/apt/sources.list && \
    echo "deb http://mirrors.ustc.edu.cn/debian/ stretch-updates main non-free contrib" >> /etc/apt/sources.list  && \
    echo "deb http://mirrors.ustc.edu.cn/debian/ stretch-backports main non-free contrib" >> /etc/apt/sources.list && \
    echo "deb-src http://mirrors.ustc.edu.cn/debian/ stretch main non-free contrib" >> /etc/apt/sources.list && \
    echo "deb-src http://mirrors.ustc.edu.cn/debian/ stretch-updates main non-free contrib" >> /etc/apt/sources.list && \
    echo "deb-src http://mirrors.ustc.edu.cn/debian/ stretch-backports main non-free contrib" >> /etc/apt/sources.list && \
    echo "deb http://mirrors.ustc.edu.cn/debian-security/ stretch/updates main non-free contrib" >> /etc/apt/sources.list && \
    echo "deb-src http://mirrors.ustc.edu.cn/debian-security/ stretch/updates main non-free contrib" >> /etc/apt/sources.list

Debian (wheezy)

# 更新阿里云的wheezy版本包源
RUN echo "deb http://mirrors.aliyun.com/debian wheezy main contrib non-free" > /etc/apt/sources.list && \
    echo "deb-src http://mirrors.aliyun.com/debian wheezy main contrib non-free" >> /etc/apt/sources.list  && \
    echo "deb http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free" >> /etc/apt/sources.list && \
    echo "deb-src http://mirrors.aliyun.com/debian wheezy-updates main contrib non-free" >> /etc/apt/sources.list && \
    echo "deb http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free" >> /etc/apt/sources.list && \
    echo "deb-src http://mirrors.aliyun.com/debian-security wheezy/updates main contrib non-free" >> /etc/apt/sources.list

上述配置针对采用阿里云提供的debian 7(wheezy)的镜像源,如果采用jessie或者stretch的系统,可以替换wheezy关键词即可。
如果采用网易提供的镜像源,将上述地址替换为:

 http://mirrors.163.com/debian/

References

在构建基于debian的docker基础镜像时,更换国内包源
原 加速Docker镜像编译之更换软件源