Nextcloud Rockon with postgres

Hello,

i’m playing around with a Nextcloud Rockon. I’ve read the pull request

and as mentioned in the comments there, i also would like to use an externel database like postgres. I’ve looked into the owncloud.json

and used it as an example how to link the nextcloud container with a postgres container.

        "container_links": {
        "owncloud": [
            {
                "name": "db",
                "source_container": "owncloud-postgres"
            }
        ]

},

Since this owncloud Rockon doesn’t work on my Rockstor installation, my first question would be if linking cointainers does work that way?

Hi @Bert!

Yes, container links in the Rockons are supposed to work that way but the linked container also needs to have the correct name, etc… Maybe you could provide more information as the error you are getting, along with the full JSON file you are testing?

I have a custom nextcloud rock on that works if you’d like me to post it?

Hi @Flox,

sorry for the belated reply, your help is much appreciated. My testing JSON file looks that way:

{
    "Nextcloud-Official": {
	    "description": "A safe home for all your data with postgres database",
        "version": "latest",
        "website": "https://hub.docker.com/_/nextcloud/",
		"more_info": "<p>You... http://ROCKSTOR_IP:GUI_PORT.</p><p>Note...</p><p><h4>IMPORTANT: ...</h4></p>",		
        "ui": {
            "slug": ""
        },
        "volume_add_support": false,
        "container_links": {
            "nextcloud": [
                {
                    "name": "postgres",
                    "source_container": "nextcloud-postgres"
                }
            ]
		},
        "containers": {
            "nextcloud": {
                "image": "nextcloud",
				"tag": "latest",
                "launch_order": 2,
                "ports": {
                    "80": {
                        "description": "Port for access GUI with browser",
                        "label": "GUI Port",		
                        "host_default": 8198,
                        "ui": true
                    }
                },
                "volumes": {
                    "/var/www/html/": {
                        "description": "Choose a persistent Nextcloud share on host. Eg: create a Share called ro-nc-data for this purpose alone.",
                        "label": "Config Nextcloud data share",
						"min_size": 1073741824
                    }
                },				
                "environment": {
                    "POSTGRES_PASSWORD": {
                        "description": "Password for the database user",
                        "label": "Superuser password for PostgreSQL",
                        "index": 1
                    },
					"POSTGRES_USER": {
                        "description": "Username for the database using postgres",
                        "label": "User with superuser power",
                        "index": 2
                    }
                },
				"opts": [
                    [
                        "POSTGRES_DB",
                        "postgres"
                    ]
				]
            },
            "nextcloud-postgres": {
                "image": "postgres",
				"tag": "latest",
                "launch_order": 1,
                "volumes": {
                    "/var/lib/postgresql/data": {
                        "description": "Choose a Share for Nextcloud's postgresql database. Eg: create a Share called Nextcloud-db for this purpose alone.",
                        "label": "DB Storage",
                        "min_size": 1073741824
                    }
                }
			}
        }
    }
}

As far as i can see, both docker containers get installed, but they are not linked.
Also the environment objects aren’t read by the nextcloud container.

Unfortunately my knowledge in docker container is so small, that i can’t debug it myself.

@Michael_Arthur
If you could post it, that would be great. I’m very interested.

Thanks
Bert

Sure, will post asap

{
"Nextcloud": {
    "container_links": {
        "nextcloud": [
            {
                "name": "nextcloud-db",
                "source_container": "nextcloud-db"
            }
        ]
    },
    "containers": {
        "nextcloud": {
            "image": "jumblesoft/docker-nextcloud",
	"tag": "latest",
            "launch_order": 2,
            "ports": {
                "80": {
                    "description": "Nextcloud WebUI port. Suggested default: 80",
                    "host_default": 8484,
                    "label": "WebUI port",
                    "protocol": "tcp",
                    "ui": true
                }
            },
            "volumes": {
                "/config": {
                    "description": "Choose a Share for Nextcloud configuration (e.g. config.php).",
                    "label": "Config Storage",
                    "min_size": 1073741824
                },
                "/data": {
                    "description": "Choose a Share for Nextcloud data.",
                    "label": "Data Storage",
                    "min_size": 1073741824
                },
                "/apps2": {
                    "description": "Choose a Share for Nextcloud downloaded apps",
                    "label": "App Storage",
                    "min_size": 1073741824
                }
            },
            "opts": [
                [
                    "-e",
                    "DB_TYPE=mysql"
                ],
                [
                    "-e",
                    "DB_HOST=nextcloud-db"
                ],
                [
                    "--link",
                    "nextcloud-db"
                ]
            ],
            "environment": {}
        },
        "nextcloud-db": {
            "image": "mariadb:10.3",
	"tag": "10",
            "launch_order": 1,
            "volumes": {
                "/var/lib/mysql": {
                    "description": "Choose a Share for Nextclouds's mysql database.",
                    "label": "Database Storage",
                    "min_size": 1073741824
                }
            },
            "opts": [
                [
                    "-e",
                    "MYSQL_ROOT_PASSWORD=ROOT_PASSWORD"
                ],
                [
                    "-e",
                    "MYSQL_DATABASE=nextcloud"
                ],
                [
                    "-e",
                    "MYSQL_USER=nextcloud"
                ],
                [
                    "-e",
                    "MYSQL_PASSWORD=nextcloud"
                ]
            ],
            "environment": {}
         }
    },
    "version": "latest stable",
    "description": "Secure file sharing and hosting",
    "icon": "https://nextcloud.com/wp-content/themes/next/assets/img/common/nextcloud-square-logo.png",
    "more_info": "<p>More info...</p>",
    "ui": {
        "https": true,
        "slug": ""
    },
    "website": "https://nextcloud.com/"
}

}

Hi @Bert, sorry for not getting back with you earlier while I should have.
I think you actually made me realize something odd with the way we’re dealing with the "container_links" object in the json file, or more accurately the fact that we are not dealing with it for general Rock-ons. It appears to me that it may be a remnant of early owncloud rock-on stage… If that is the case, maybe it should be corrected in the documentation / readme. @phillxnet, do you know if that’s the case?
This would thus mean that my previous post was erroneous and that the correct way would be to simply take care of the container links in the "options" object, as @Michael_Arthur has done in its json file.

I apologize for my previously incorrect post.

@Flox

I don’t know as it goes. Would have to look at the code but I seem to remember that there are some ‘special cases’ in there that may have been intended to be of more general use. Just not that up on the Rock-on code myself as of yet.

So not much help I’m afraid.

In cases of translating docker composes like this one directly, the user is required to create a new docker network, then add the containers to it.

They require a new network because the default bridge network doesn’t support DNS, which means that the use of container names for ENV vars such as

                [
                    "-e",
                    "DB_HOST=nextcloud-db"
                ],

will not work (ever). There is further discussion in this issue.

2 Likes