Docker Community Forums

Share and learn in the Docker community.

LibreOffice headless on Windows Server Core

(Gabriel Muñoz) #1

I am trying to create a headless installation of LibreOffice under Windows Server Core 2016. My goal is to have a container that allow me to create on the fly documents based on templates. I have done it previously with a Linux-based image (something like this:, but now I need the same to be run under Docker for Windows Server 2016.

I am able to make an unnatended installation of LibreOffice 5.3 under Windows Server Core from my Dockerfile:

RUN powershell -Command _
_ $ErrorActionPreference = ‘Stop’; \ _
_ Invoke-WebRequest -Method Get -Uri %LIBREOFFICE_URL% -OutFile c:\LibreOffice.msi ; _
_ Start-Process c:\LibreOffice.msi -ArgumentList ‘/qr /msoreg=0 ADDLOCAL=ALL CREATEDESKTOPLINKE=0 REGISTER_ALL_SMO_TYPES=1 REGISTER_DOC=1 INSTALLLOCATION=c:\LibreOffice REMOVE=gm_o_Onlineupdate,gm_p_Base,gm_p_Base_Bin,gm_o_Xsltfiltersamples RebootYesNo=No’ -Wait ; \ _
_ Remove-Item c:\LibreOffice.msi -Force

However LibreOffice does not work after installed:

CMD “C:\LibreOffice\program\soffice.exe -headless -accept=‘socket,host=,port=8101;urp;’ -nofirststartwizard”

With no error message and no clue about the problem. I suppose is some related with the absense of GUI (despite the fact that the headless mode has been made to run LibreOffice as a service).

Has anyone tried to to the same?

(Gabriel Muñoz) #2

I have solved the problem using LibreOffice 5.4.1

(Brandon Boone) #3

I’m looking to do the same thing. I can successfully start the container and see that LibreOffice is listening on the port, but my program hangs.

C:\>docker run -d --name some-office -p 8101:8101 libreoffice

C:\>netstat -nao|findstr -c:"8101"
TCP              LISTENING       17264

I’m using the CLI interface via C# on the host machine.

var xLocalContext = uno.util.Bootstrap.defaultBootstrap_InitialComponentContext();

var xURLResolver = (XUnoUrlResolver)xLocalContext.getServiceManager().createInstanceWithContext("", xLocalContext);

// m_ServiceConnString = uno:socket,host=localhost,port=8101;urp;StarOffice.ComponentContext
var xRemoteContext = (XComponentContext)xURLResolver.resolve(m_ServiceConnString); //C# never returns from this line and doesn't error

var xRemoteFactory = (XMultiServiceFactory)xRemoteContext.getServiceManager();
 return (XComponentLoader)xRemoteFactory.createInstance("");

Running an identical version of LibreOffice locally works fine. Any pointers you have would be greatly appreciated!

(Gabriel Muñoz) #4

Could you try using the Docker image aytos/libreofffice:v1-windows? If it works ok for you, I can give you the Dockerfile.

We are using this image in several production environments and generating documents using it from a Java web application succesfully.

(Brandon Boone) #5

Thanks for the offer. I was able to figure out my issue:, but I may take a look at your image anyway. Off hand, do you know if LibreOffice running headless in a Linux container can communicate successfully with a Windows machine. The windows container is massive by comparison, but I get “binary urp bridge disposed during call” with the Linux version of LibreOffice running in a Linux Container. This is why I went down the windows container route in the first place.