This one had me struggle quite a bit.
I felt like this is something that cannot possibly be super hard to setup.
Before running Nextcloud in a VM I remember the setup to be quite trivial.

And once again it has proven to be true that there are only three networking issues. DNS DNS and DNS. But lets take a step back.

I am running a Nextcloud for my family and wanted to integrate collabora.

This is the How-To I used:

Collabora, much like Google Docs or Office365, enables you to edit documents online in your browser. Collabora is a child of Libreoffice Online. The Idea is to still perform well even if 20 people or more are working on a document simultaneously.

The average collabora installation guide is using the collabora\code docker container. It expect you to run it in a “classical” nextcloud setup in wich the Apache or Nginx Server is run on the Aplication Layer of the Host Operating System of the Server.

In such a setup the docker container is running in the kernelspace of the host machine that is hooked up to the internet.

If we now add a layer of virtualisation things become a little more tricky.

The docker container is still running in the same kernelspace as the nextcloud instance. However the NAT is having some effects on the DNS resolution.

The docker container gets run using the hostname for the subdomain that will be used by the webserver for the rewrite rules interacting with the docker container.

sudo docker run -t -d -p -e 'domain=nextcloud\\.your-domain\\.com' --restart always --cap-add MKNOD collabora/code

If we run this setup without nat, the docker container can resolve to

Then the container can speak to the nextcloud using the loopback interface.
Behind a nat, this is not working.

A simple change does the trick.
We will have to edit the hosts file inside the docker conainer.

EDIT: Docker has a parameter to perform this task (since version 17) called –add-host. Using this option your changes wont be lost if the container restarts (e.g. if the host reboots). Lets say the IP of your Nextcloud behind the NAT is Then you will have to start the container like this:

sudo docker run -t -d -p -e 'domain=nextcloud\\.your-domain\\.com' --restart always --cap-add MKNOD collabora/code

General container debugging

EDIT: I will leave this bit in for general purpose docker container debugging.

Check docker ps -a to find the name the collabora docker container has been assigned. Then start a shell inside the container using docker exec -i -t <ContainerName> /bin/bash.

There we edit the /etc/hosts file and add two lines.
One for and one for It worked best for me using the IP address of the virtual machine.

Beeing lazy I did run apt update and apt install vi to have an editor inside of the container. You could also just echo it into the hosts file.

Afterwards you also need to edit the /etc/hosts file of the VM.
To be able to properly communicate with the container I had to have resolve to rather then my public IP.