Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker compose persistence #2904

Open
slawrence-miso opened this issue Jan 22, 2025 · 1 comment
Open

Docker compose persistence #2904

slawrence-miso opened this issue Jan 22, 2025 · 1 comment

Comments

@slawrence-miso
Copy link

When I try to use the docker compose examples I am only able to have persistence between container restarts. If I kill the containers using down I end up with errors such as this:

oracle-1     | ####################################################################
oracle-1     | CONTAINER: The following output is now from the alert_FREE.log file:
oracle-1     | ####################################################################
oracle-1     | ===========================================================
oracle-1     | 2025-01-22T15:04:24.567114+00:00
oracle-1     | Errors in file /opt/oracle/diag/rdbms/free/FREE/trace/FREE_p000_163.trc:
oracle-1     | ORA-01157: cannot identify/lock data file 24 - see DBWR trace file
oracle-1     | ORA-01110: data file 24: '/opt/oracle/product/23ai/dbhomeFree/dbs/DATA'
oracle-1     | 2025-01-22T15:04:24.568492+00:00
oracle-1     | Errors in file /opt/oracle/diag/rdbms/free/FREE/trace/FREE_ora_155.trc:
oracle-1     | ORA-01157: cannot identify/lock data file 24 - see DBWR trace file
oracle-1     | ORA-01110: data file 24: '/opt/oracle/product/23ai/dbhomeFree/dbs/DATA'
oracle-1     | Completed: ALTER DATABASE OPEN
oracle-1     | 2025-01-22T15:04:25.150297+00:00
oracle-1     | Errors in file /opt/oracle/diag/rdbms/free/FREE/trace/FREE_mz00_412.trc:
oracle-1     | ORA-01110: data file 24: '/opt/oracle/product/23ai/dbhomeFree/dbs/DATA'
oracle-1     | ORA-01565: Error identifying file /opt/oracle/product/23ai/dbhomeFree/dbs/DATA.
oracle-1     | ORA-27037: unable to obtain file status
oracle-1     | Linux-x86_64 Error: 2: No such file or directory
oracle-1     | Additional information: 7
oracle-1     | Checker run found 1 new persistent data failures

I am configuring the volume like this:

volumes:
  - oracle-volume:/opt/oracle/oradata

I found some discussions about using a DATAFILE option during the tablespace creation, and maybe that is an option that would work, but I was unable to find where that is happening.

@oraclesean
Copy link
Contributor

The volume configuration you've defined creates an anonymous volume. Running compose down doesn't drop the volume, but it doesn't have a name that subsequent compose up commands recognize, so compose doesn't remount the volume. See https://docs.docker.com/reference/cli/docker/compose/down/ for more information.

To solve this, use a named volume bind-mount instead. I recommend this option, since it gives you control over the location of the database datafiles. Anonymous or unbound named volumes are saved under the protected /var/lib/docker directory (or its equivalent) where you have limited visibility. First, create a volume and assign it to a local directory:

docker volume create --opt type=none --opt o=bind --opt device=/some/directory oracledb_data

Then, reference the named volume in your compose specification:

services:
  oracledb:
<snip>
    volumes:
      - oracledb_data:/opt/oracle/oradata
<snip>

volumes:
  oracledb_data:
    external: true

If you prefer to use an unbound volume, the steps are:

docker volume create oracledb_data

The compose yaml file looks nearly identical; just exclude the external: true property within the volume definition:

services:
  oracledb:
<snip>
    volumes:
      - oracledb_data:/opt/oracle/oradata
<snip>

volumes:
  oracledb_data:

If you've run compose up and compose down, you'll likely have orphaned volumes that are taking up space and it's probably wise to clean them up. :) List them with:

docker volume ls

And remove them using:

docker volume rm <volume name>

(Running docker compose down -v removes volumes defined in the compose specification.)

HTH!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants