.net core部署在CentOS上时关于使用GDI报错的问题
一运行到gdi相关的代码时,就报如上图片所示的错误。
关于这个的解决办法,其实是需要在centos上安装libgdiplus
首先,搜索libgdiplus
yum whatprovides libgdiplus
然后执行命令安装即可
yum install libgdiplus
如果是docker容器内部出现GDI错误:
首先先docker ps,找到我们要针对的容器
然后使用这个container id进入到容器内部(注意以下的容器ID都要替换成自己的,这里只是作为示范)
docker exec -it d87fd1971126 /bin/bash
安装GDI+
apt-get update
apt-get install libgdiplus
安装完成之后,退出容器,重启该容器
exit
docker stop d87fd1971126
docker restart d87fd1971126
如果考虑到持续交付的话,最好的办法就应该是创建镜像的时候,里面就包含着这个东西。
所以为了实现这个需求,接下来需要修改Dockerfile文件,添加以下内容
#修改为163源 RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \ echo "deb http://mirrors.163.com/debian/ stretch main non-free contrib" >> /etc/apt/sources.list && \ echo "deb http://mirrors.163.com/debian/ stretch-updates main non-free contrib" >> /etc/apt/sources.list && \ echo "deb http://mirrors.163.com/debian/ stretch-backports main non-free contrib" >> /etc/apt/sources.list && \ echo "deb-src http://mirrors.163.com/debian/ stretch main non-free contrib" >> /etc/apt/sources.list && \ echo "deb-src http://mirrors.163.com/debian/ stretch-updates main non-free contrib" >> /etc/apt/sources.list && \ echo "deb-src http://mirrors.163.com/debian/ stretch-backports main non-free contrib" >> /etc/apt/sources.list && \ echo "deb http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib" >> /etc/apt/sources.list && \ echo "deb-src http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib" >> /etc/apt/sources.list #apt-get update 以及安装一些包 RUN apt-get update && apt-get install -y libgdiplus