本文主要是介绍[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']
----
这篇关于[web-031]配置utc+8时区的alpine最小尺寸(66M)flask镜像的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!