关于.net core 3.0 docker 部署 System.Drawing.Common 的问题

问题:docker

  .net core 3.0 使用 mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim 做为基础镜像,在开发中用到了绘图的功能,跑起来发现缺乏 libgdiplus网络

解决方案:ui

  参考:https://q.cnblogs.com/q/109061/.net

  只须要在容器中安装 libgdiplus libc6-dev 便可成功。blog

思考:ip

  一个项目中用到直接解决便可,当多个项目中用到每次都去安装那真是要崩溃...有什么解决方案呢?开发

解决:get

  本身作一个带gdi+的基础镜像不就行了,dockerfile 也很简单:dockerfile

  ******************************Dockerfile**********************************it

  FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim

  RUN echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free \
  deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free \
  deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free \
  deb https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free \
  " > /etc/apt/sources.list

  RUN apt-get update
  RUN apt-get install -y --no-install-recommends libgdiplus libc6-dev

  ******************************Dockerfile**********************************

  第二行是添加清华大学的源,用官方源人品就是success,人品很差就是 Unable to locate package xxx(开玩笑,网络实在是...)

  docker build -t mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-gdi .

  完美,须要绘图的就基于这个镜像就能够了。

相关文章
相关标签/搜索