zoukankan      html  css  js  c++  java
  • 使用 Alpine 作为基础镜像时可能会遇到的常见问题的解决方法

    1、使用Alpine基础镜像下载软件包时报错

    Dockerfile

    FROM alpine:3.11
    
    RUN apk add --no-cache ca-certificates
    # To speed up building process, we copy binary directly from make
    # result instead of building it again, so make sure you run the
    # following command first before building docker image
    #   make cb-apiserver
    #
    COPY  cb-apiserver /usr/local/bin/
    
    EXPOSE 9090
    CMD ["sh"]

    原因:alpine 镜像默认的软件仓库在国外,有时 docker build 的时候安装软件包会很慢。 

    解决方法:使用国内的软件包镜像,比如 https://mirrors.ustc.edu.cn 的镜像:

    Dockerfile加上下面这行:

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

     参考:https://mozillazg.com/2020/03/use-alpine-image-common-issues.rst.html 

    2、go get程序包超时

    Dockerfile加上下面这行:

    ENV GOPROXY=https://goproxy.cn,direct
  • 相关阅读:
    Mysql安装
    Python的内存管理机制
    Ansible模块
    Redis持久化
    Linux——ansible(1)
    Flask
    Flask入门
    ajax处理回调函数,用ajax向后台发送数据
    数字类型钱币转换为大写
    ligerui多选动态下拉框
  • 原文地址:https://www.cnblogs.com/zhangmingcheng/p/14465679.html
Copyright © 2011-2022 走看看