Search code examples
databasedockercontainersorganization

Docker database files: inside or outside the container?


We've been looking into implementing an Oracle Database system using Docker on our server and are considering two different strategies for managing our data:

  • Storing the database files (.dbfs) in a folder on the server's path, and then making that folder available in a container using the -v option. The idea is to have multiple containers accessing multiple folders so we can manage different versions of our data.
  • Keeping the database files inside the container as if it were a regular installation.

The reason behind this is that we like the idea of being able to change versions on the fly, when we need to revert to an old version of our program to fix a bug (for example if an older version is in production than the one we're currently working on). In that sense, the containers we have should also have a specific version of our app in them (it's a webapp).

So my question is the following: which approach would be the best in our case? Is there another organization of our containers that we missed and would be better? Looking for more opinions on the matter. We've been told already that the first method would perform better than keeping everything in containers, but our tests have not shown any improvement.

Thanks!


Solution

  • Go with the first option and forget the second one because you don't want to make any intensive disk access on a Docker layered file system.

    Docker containers have a layered file system which does not deliver great performances. That's why you should have your data on a volume which is in the end a mount point on a folder in your docker host file system.

    If you look at all official docker images for databases, they all declare volumes for the data. See MySQL, Postgres