Docker with external database

I noticed that there is a docker version for owncloud.
Since I will migrate soon my owncloud server to a more powerful one, I would have like to have it dockerised.

I already have a mysql server (dockerised)running on my new server and I would like to use that DB instead of another one that owncloud will create.

How can I start an owncloud docker and connect to external db?


Check if has enough information.
There are some environment variables you can use when you start the docker container:

  -e OWNCLOUD_DB_TYPE=mysql \
  -e OWNCLOUD_DB_NAME=owncloud \
  -e OWNCLOUD_DB_USERNAME=owncloud \
  -e OWNCLOUD_DB_PASSWORD=owncloud \

Does settings look like setting for the nwe mysql that docker will spawn isn’t it?

It depends on what you want to do. The “basic” container just spawns and apache with ownCloud. You can use those variables to connect to a mysql instance anywhere (I don’t see a port, so I guees it will connect using the default mysql port).

If you’re using docker-compose and the “recommended” .yml file (, that file define both mysql and redis services which will also be spawned along with ownCloud. It’s also tailored to connect the 3 services together with a minimal information you need to provide, in particular, the connection to the DB is already setup to connect to the new spawned DB service.

You can modify that file at will (know what you’re doing), so you can remove the DB service, and connect to an external one.
Note that I don’t recommend to do this. It might be useful if you have a DB service running in another host

In case anyone finds this and is still looking for an answer to this question, you can set a custom MySQL port using the OWNCLOUD_DB_HOST environmental variable by setting it equal to “host:port”… ie: “mydatabasehost.local:13306”. Confirmed working on 10.3.2 at least.