ReinerNippes / nextcloud_on_docker

Run Nextcloud in Docker Container on various Linux Hosts
MIT License
203 stars 48 forks source link

Multiple docker containers on same server #58

Closed asoral closed 3 years ago

asoral commented 4 years ago

I might be missing something but please help me understand this. I am trying to use this script to install nextcloud and it works just fine for the first time. Now, I want to use the same script, on the same VM and install another docker for nextcloud. My questions -

  1. What all values should I change in what all files to make this happen?
  2. Where is it defined that the port number for nextcloud is 80 and that of ssl is 443. Can I change this and have multiple containers running on the same machine?

Please help me here!

ReinerNippes commented 4 years ago
2\. Where is it defined that the port number for nextcloud is 80 and that of ssl is 443.

That is defined in the traefik.toml line 6 & 11.

https://github.com/ReinerNippes/nextcloud_on_docker/blob/bab3d3b24a83ec87fcfed9ad230e3eb186ee10df/roles/docker_container/templates/traefik.toml.j2#L6 https://github.com/ReinerNippes/nextcloud_on_docker/blob/bab3d3b24a83ec87fcfed9ad230e3eb186ee10df/roles/docker_container/templates/traefik.toml.j2#L11

2\. Can I change this and have multiple containers running on the same machine?

With a lot of work. Maybe.

If you want to run different nextcloud instances on different ports you have to define for each one another entrypoint. Like it's done for onlyoffice.

https://github.com/ReinerNippes/nextcloud_on_docker/blob/bab3d3b24a83ec87fcfed9ad230e3eb186ee10df/roles/docker_container/templates/traefik.toml.j2#L29

So traefik will listen on all these ports. That's the easy part.

Now you have to find all container tasks needed to setup a nextcloud instance.

https://github.com/ReinerNippes/nextcloud_on_docker/blob/bab3d3b24a83ec87fcfed9ad230e3eb186ee10df/roles/docker_container/tasks/nextcloud.yml#L32

That is at least nextcloud + nginx (in case you use the fpm container).

You have to give the container different namens (nextcloud00, nextcloud01, nextcloud02, ...)

https://github.com/ReinerNippes/nextcloud_on_docker/blob/bab3d3b24a83ec87fcfed9ad230e3eb186ee10df/roles/docker_container/tasks/nextcloud.yml#L33

You have to make sure that they all use different data and config folders

https://github.com/ReinerNippes/nextcloud_on_docker/blob/bab3d3b24a83ec87fcfed9ad230e3eb186ee10df/roles/docker_container/tasks/nextcloud.yml#L40

and you have to modify the config tasks.

https://github.com/ReinerNippes/nextcloud_on_docker/blob/bab3d3b24a83ec87fcfed9ad230e3eb186ee10df/roles/nextcloud_config/tasks/main.yml#L10

as you can see in the command above the container name is always "nextcloud".

When I was writing this playbook I didn't had a multi nextcloud environment in mind.

The good news: You look at the playbook ReinerNippes/selfhosted_on_docker.

There you can define a set of nextcloud instances.

  - name: nextcloud00
    type: nextcloud
    server_fqdn: nextcloud00.{{ base_domain }}
    collabora:   true
    collabora_dictionaries: "de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru"
    onlyoffice:  true
    talk:        true
    talk_server: base.{{ base_domain }}
  - name: nextcloud01
    type: nextcloud
    server_fqdn: nextcloud01.{{ base_domain }}
    collabora:   true
    collabora_dictionaries: "de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru"
    onlyoffice:  true
    talk:        true
    talk_server: base.{{ base_domain }}
  - name: nextcloud02
    type: nextcloud
    server_fqdn: nextcloud02.{{ base_domain }}
    collabora:   true
    collabora_dictionaries: "de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru"
    onlyoffice:  true
    talk:        true
    talk_server: base.{{ base_domain }}

Nevertheless they won't run on different ports but different dns names.