[web-031]配置utc+8时区的alpine最小尺寸(66M)flask镜像

1.参考文献

https://blog.csdn.net/qq_43200350/article/details/100108419
https://blog.csdn.net/csdn_duomaomao/article/details/76152416
https://www.jianshu.com/p/6fa94d6222d2
https://blog.csdn.net/liumiaocn/article/details/87603628


2.流程

拉镜像
docker pull alpine:latest
docker pull alpine:3.5

运行alpine 
docker run -it --name myalpine alpine
启动后可以执行bash命令

连接到一个正在运行的alpine容器,以便做调试
docker exec -it 1746  sh #1746是容器id,可以根据具体容器id替换

更新apk索引,准备安装软件
apk update

安装python3
apk add --no-cache python3

安装flask
pip3 install flask


3. alpine作为容器基础镜像,需要同步时区

https://www.cnblogs.com/javacspring/p/6172327.html
https://www.jianshu.com/p/cd1636c94f9f

ENV  TIME_ZONE Asiz/Shanghai
RUN apk add --no-cache tzdata && echo "${TIME_ZONE}" > /etc/timezone && ln -sf /usr/share/zoneinfo/${TIME_ZONE} /etc/localtime && apk del tzdata


4 alpine对python3的支持

FROM registry.docker-cn.com/library/alpine:3.5
COPY . /target-dir
WORKDIR /target-dir
RUN sed -i 's/dl-cdn.alpinelinux.org/mirror.tuna.tsinghua.edu.cn/g' /etc/apk/repositories &&\
apk add --no-cache python3 && \
apk add --no-cache --virtual=build-dependencies \
    mariadb-dev\
    g++ \
    build-base libffi-dev python3-dev \
    libffi openssl ca-certificates \
    jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev \
    linux-headers pcre-dev  && \
pip3 install --upgrade pip  --no-cache-dir -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com &&\
pip3 install --no-cache-dir -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com -r /target-dir/requirements.txt && \
apk del g++ mariadb-dev && \
apk add --no-cache mariadb-client-libs && \
apk del --purge \
build-dependencies && \
rm -rf \
/root/.cache \
/tmp/*


5.最小flask镜像Dockerfile
----
#运行
#docker run -it image_id
#可以根据本文件增加其他功能

from alpine:latest

ENV  TIME_ZONE Asiz/Shanghai

ENV LANG C.UTF-8
RUN apk update && apk add --no-cache tzdata && echo "${TIME_ZONE}" > /etc/timezone && ln -sf /usr/share/zoneinfo/${TIME_ZONE} /etc/localtime && apk del tzdata && apk add --no-cache python3 && pip3 install flask

#ENTRYPOINT ['/bin/sh']
----
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值