Create new nextcloud container to existing mysql-container

Hello together

I have a question regarding Nextcloud and containers.

I have created a compose file which contains mysql, nextloud and npm. This works very well! Now I want to create another nextcloud container which connects to the existing mysql container. In there the user and the database for the new nextcloud container was already created.

How must the docker-compose-file look like for this?

version: '3'



    image: nextcloud
    restart: always
      - nextcloud-data-x:/var/www/html
      - MYSQL_USER=nextcloudx
      - MYSQL_HOST=nextcloud-db
      - frontend
      - backend

Could you please let me know what I am doing wrong or how to do it right?

Thanks a lot!!

Sorry i do actually not use Docker. But i think the configuration for nextcloud 1 and nextcloud 2 must almost be the same. Both connect to the same MariaDB but different structures. I have never tried it. But maybe even the same database user can be used. Whereby I would create a second user for this.

Perhaps you can post the differences between the both nextcloud instances to find the error.

you can trick both NC instances to use same sql DB but why? using docker is pretty lightweight so running two separated SQL instances doesn’t add noticeable load on your system but highly improves your system stability and resiliency - when you are working on one pair of NC/SQL the other is untouched. using different networks for NC1/SQL1 and NC2/SQL2 gives you better separation and results in more security…

I recommend you don’t share resources between different systems in Docker environment - try to keep 1:1 ratio of frontend/backend systems - unless you have to (like ingress reverse proxy) - back-end DB definitely doesn’t count into this category…


Thanks a lot!! you really helped me out :slight_smile: