'Libreoffice convert-to not working in AWS docker image

I trying to convert a file to pdf using libreoffice, currently the best I achived is:

RUN wget http://download.documentfoundation.org/libreoffice/stable/7.2.5/rpm/x86_64/LibreOffice_7.2.5_Linux_x86-64_rpm.tar.gz
RUN tar -xvzf LibreOffice_7.2.5_Linux_x86-64_rpm.tar.gz
RUN cd LibreOffice_7.2.5.2_Linux_x86-64_rpm/RPMS; yum -y localinstall *.rpm;
RUN yum -y install cairo
RUN echo instalacion completada
RUN /opt/libreoffice7.2/program/soffice.bin --version

Until here, works! Shows the version of libreoffice correctly installed, but when trying to run, it does not work:

RUN /opt/libreoffice7.2/program/soffice.bin --headless --convert-to pdf my_file.xlsm

Returns:

The command '/bin/sh -c /opt/libreoffice7.2/program/soffice.bin --headless --convert-to pdf my_file.xlsm' returned a non-zero code: 81

My complete Dockerfile

# Pull the base image with python 3.8 as a runtime for your Lambda
FROM public.ecr.aws/lambda/python:3.8

RUN mkdir experimento/
COPY my_file.xlsm .

# Install OS packages for Pillow-SIMD
RUN yum -y install wget tar gzip zlib freetype-devel \
    gcc \
    ghostscript \
    lcms2-devel \
    libffi-devel \
    libimagequant-devel \
    libjpeg-devel \
    libraqm-devel \
    libtiff-devel \
    libwebp-devel \
    make \
    openjpeg2-devel \
    rh-python36 \
    rh-python36-python-virtualenv \
    sudo \
    tcl-devel \
    tk-devel \
    tkinter \
    which \
    xorg-x11-server-Xvfb \
    zlib-devel \
    && yum clean all

RUN wget http://download.documentfoundation.org/libreoffice/stable/7.2.5/rpm/x86_64/LibreOffice_7.2.5_Linux_x86-64_rpm.tar.gz
RUN tar -xvzf LibreOffice_7.2.5_Linux_x86-64_rpm.tar.gz
RUN cd LibreOffice_7.2.5.2_Linux_x86-64_rpm/RPMS; yum -y localinstall *.rpm;
RUN yum -y install cairo
RUN echo instalacion completada
RUN /opt/libreoffice7.2/program/soffice.bin --version
RUN /opt/libreoffice7.2/program/soffice.bin -h
RUN sudo find / -name soffice.bin
RUN yum install -y libXinerama.x86_64 cups-libs dbus-glib
RUN sudo /opt/libreoffice7.2/program/soffice.bin --headless --invisible --nodefault --nofirststartwizard --nolockcheck --nologo --norestore --convert-to 'pdf:writer_pdf_Export' --outdir experimento/ my_file.xlsm


Solution 1:[1]

I found a solution, the problem was .bin at the end of soffice:

# Pull the base image with python 3.8 as a runtime for your Lambda
FROM public.ecr.aws/lambda/python:3.8

COPY my_file.xlsm .

# Install OS packages for Pillow-SIMD
RUN yum -y install curl wget tar gzip zlib freetype-devel \
    libxslt \
    libxslt1-dev \
    gcc \
    ghostscript \
    lcms2-devel \
    libffi-devel \
    libimagequant-devel \
    libjpeg-devel \
    libraqm-devel \
    libtiff-devel \
    libwebp-devel \
    make \
    openjpeg2-devel \
    rh-python36 \
    rh-python36-python-virtualenv \
    sudo \
    tcl-devel \
    tk-devel \
    tkinter \
    which \
    xorg-x11-server-Xvfb \
    zlib-devel \
    java \
    && yum clean all

RUN wget http://download.documentfoundation.org/libreoffice/stable/7.2.5/rpm/x86_64/LibreOffice_7.2.5_Linux_x86-64_rpm.tar.gz 
RUN tar -xvzf LibreOffice_7.2.5_Linux_x86-64_rpm.tar.gz
RUN cd LibreOffice_7.2.5.2_Linux_x86-64_rpm/RPMS; yum -y localinstall *.rpm;
RUN yum -y install cairo
RUN /opt/libreoffice7.2/program/soffice.bin --version
COPY carta_2020.xlsm /tmp/
RUN ls /tmp/
RUN /opt/libreoffice7.2/program/soffice --headless --convert-to pdf --outdir /tmp my_file.xlsm

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ambigus9