• aspnetcore3.1通过dockerfile发布到docker遇到的坑


    内在影响

      环境:window 10,docker2.3.0.2,vs 2019 

      外部资源:mssql(2016),reides

      发布内容:web api (http:若创建时点击了支持https也没有关系,不影响发布http)

    正常步骤:

    1.右键点击项目->添加->支持docker

    2.修改Dockerfile

    3.发布docker成功

    非正常步骤:

    1.镜像无法下载,修改dockerfile的镜像(使用阿里镜像)

    mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim  -> registry.cn-chengdu.aliyuncs.com/jimlicatpub/aspnet:3.1-buster-slim

    mcr.microsoft.com/dotnet/core/sdk:3.1-buster -> registry.cn-chengdu.aliyuncs.com/jimlicatpub/dotnet-sdk:3.1-buste

    2.无法连接数据库

      错误信息:SSL Handshake failed with OpenSSL error

      解决方案:修改dockerfile文件 -> 添加 RUN sed -i 's/TLSv1.2/TLSv1.0/g' /etc/ssl/openssl.cnf (ps:也有说添加 RUN sed -i "s|DEFAULT@SECLEVEL=2|DEFAULT@SECLEVEL=1|g" /etc/ssl/openssl.cnf ,未测试)

       参考方案:

        1.https://blog.csdn.net/qq_21265915/article/details/103274624

        2.https://www.cnblogs.com/jidanfan/p/12158972.html

      ps:由于找不到原答案,所以找了两个相近的链接补上

    3.数据库连接超时
      错误信息:Connection Timeout Expired

           解决方案:查看数据库版本->sql server 2008 sp3(ps:只测试了sql server 2016、2014)(ps:也有说数据库连接超时是因为 mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim   的原因,但是在未更改数据库 为 sql server 2016时,也是无效的;后续改为sql server 2016后可以,如果高版本数据库不行,则可以考虑更改 为  mcr.microsoft.com/dotnet/core/aspnet:3.1 试试)

      参考方案:

        1.未找到原文地址,所以给一个相近的地址:https://my.oschina.net/lichaoqiang/blog/1793006

        2.测试无效,但是感觉有道理的方案:https://q.cnblogs.com/q/DetailPage/127069/

    4.aspnetcore 3.1 在Linux下,使用图片等操作导致系统错误

      错误信息:The type initializer for 'Gdip' threw an exception

      解决方案:

    RUN echo "deb http://mirrors.aliyun.com/debian stretch main contrib non-free 
    deb-src http://mirrors.aliyun.com/debian stretch main contrib non-free 
    deb http://mirrors.aliyun.com/debian stretch-updates main contrib non-free 
    deb-src http://mirrors.aliyun.com/debian stretch-updates main contrib non-free 
    deb http://mirrors.aliyun.com/debian-security stretch/updates main contrib non-free 
    deb-src http://mirrors.aliyun.com/debian-security stretch/updates main contrib non-free 
    deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib 
    deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib" > /etc/apt/sources.list
     
    RUN apt-get update && apt-get install libgdiplus -y && ln -s libgdiplus.so gdiplus.dll

    ps:

        1.镜像可能会遇到生成出错,注意命令添加位置,我是放到dockerfile末尾;

        2.打包成功但是无法运行,还是报同样的错误,将命令放到文件最后,我开始放到中间出现此问题,放到文件末尾则无此问题;

        3.镜像可能在window的打包环境可以运行,但是服务器会报"来自守护程序的错误响应:未指定命令",我的解决方案是删除本地docker库中打包程序的历史镜像,重新打包就好了

     4.个人认为有效的是“RUN apt-get update && apt-get install libgdiplus -y ”,奈何只加这一句打包会出问题,未找到原因,添加镜像是为了快速拉取

     5.未找到原博客的引用地址,后续若有找到则添加

  • 相关阅读:
    CentOS7的内核优化
    centos7 系统优化脚本
    Centos7之系统优化
    Jenkins安装
    Zabbix安装
    Systemd 入门教程:命令篇
    开源ERP系统Odoo搭建文档
    SSH详解
    使用pm2来保证Spring Boot应用稳定运行
    npm安装与使用
  • 原文地址:https://www.cnblogs.com/xiaoxiaoqiye/p/13355344.html
Copyright © 2020-2023  润新知