Reputation: 4339
I run Oracle Database 12.2.0.1 from official dockerfile. As far as I see, if I do
docker stop <container_id>
the current state of the database is lost and next time it will do some clean start.
How to shutdown the database correctly and stop the container, but save the current state?
If I do
./sqlplus sys as sysdba
SHUTDOWN IMMEDIATE
the container remains running and still consumes 11GB of 16GB of RAM, so as far as I guess, to stop the container I should probably kill some process, but it is not clear when should I do
docker commit <container_id>
so ideally I need something like shutdown_oracle_and_commit_container.sh.
Inside the docker container the oracle instance is started with runOracle.sh, but there is no stopOracle.sh
Upvotes: 3
Views: 4370
Reputation: 11
To shutdown the DB inside docker container, first
docker exec -it <name> /bin/bash
if you made it with default name, <name> = myxedb
sqlplus /nolog
conn sys/***@<db> as sysdba
in my case, <db> = //localhost:1521/XE
shutdown immediate
That's it.
Upvotes: 1
Reputation: 11050
You should use a docker volume to store the data from your database outside your container. Therefore use the -v
option and mount any path you like to store your data to /opt/oracle/oradata
inside the container.
From the docs:
-v /opt/oracle/oradata
The data volume to use for the database.
Has to be writable by the Unix "oracle" (uid: 54321) user inside the container!
If omitted the database will not be persisted over container recreation.
So according to that run:
docker run -v /path/to/your/datastore/:/opt/oracle/oradata oracle/database
The data from your database are now stored outside the container. If you use docker stop <container_id>
or even docker rm <container_id>
and you recreate a container again your data will be the same. For more information and configuration parameters see the docs.
Upvotes: 4