-
首先下载指定版本的libreoffice,注意
debian11
下需要选择Linux (64-bit) (deb)
官方下载地址:https://www.libreoffice.org/download/download-libreoffice/?type=deb-x86_64&version=7.6.2&lang=zh-CN
-
将文件上传到服务器并解压缩备用,目录结构如下:
- LibreOffice_7.6.2.1_Linux_x86-64_deb - DEBS - xxx.deb - readmes
-
准备基础镜像,我这里使用的是包含aspnet的基础镜像,当然是debian11,执行如下命令:
docker run --name dotnet-libreoffice-test -it --rm mcr.microsoft.com/dotnet/aspnet:6.0 bash
-
在容器内部,首先更新apt仓库:
mv /etc/apt/sources.list /etc/apt/sources.list.bak
echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free" >/etc/apt/sources.list echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free" >>/etc/apt/sources.list echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free" >>/etc/apt/sources.list echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free" >>/etc/apt/sources.list
apt-get update
-
安装java运行环境,注意,现在默认支持的长期版本为11,所以apt-get下安装的是11版本:
apt install default-jre
-
安装cairo
apt-get install libcairo2
有的基础镜像还需要额外安装
python-cairo
,当然我们不需要。 -
安装其他工具[top、ps、curl、ping等],可选
# 安装ps top apt-get install procps # 安装curl apt-get install curl # 安装ping apt-get install iputils-ping # 安装vi apt-get install vim
-
将LibreOffice_7.6.2.1_Linux_x86-64_deb复制到容器内部
docker cp ./LibreOffice_7.6.2.1_Linux_x86-64_deb dotnet-libreoffice-test:/
-
下面进行安装,官方安装文档:https://wiki.documentfoundation.org/Documentation/Install/Linux/zh-cn
cd /LibreOffice_7.6.2.1_Linux_x86-64_deb/DEBS
dpkg -i *.deb
-
为LibreOffice安装字体【可选】
仅安装中文字体,下载中文字体包:http://kkfileview.keking.cn/fonts.zip,解压后放在容器内的
/usr/share/fonts
目录下。安装微软的Office字体,将windows下
C:\Windows\Fonts
打包,解压后放在容器内的/usr/share/fonts
目录下即可。注意不是放目录,放解压后的所有文件,比如
C:\Windows\Fonts
下有Arial字体
,我们要做的就是把Arial字体
放到容器内的/usr/share/fonts
目录下。 -
清空本次登入的所有输出命令
history -c
-
再开另外一个窗口,进行容器的提交
docker commit dotnet-libreoffice-test aspnet-libreoffice:6.0
这时候我们的镜像就制作好了,镜像名为aspnet-libreoffice:6.0