首先下载指定版本的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,当然我们不需要。
将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
清空本次登入的所有输出命令
history -c
再开另外一个窗口,进行容器的提交
docker commit dotnet-libreoffice-test aspnet-libreoffice:6.0
这时候我们的镜像就制作好了,镜像名为aspnet-libreoffice:6.0