I have an app that uses Oracle as its DB and I'm tyring to get a Dockerized version of Oracle working locally. I'm using this Oracle image which so far is working beautifully and completely as advertised! I pulled it and am running it like so:
docker run -d -p 8080:8080 -p 1521:1521 sath89/oracle-12c
It takes a while for the container to fire up and run, several minutes actually. Below you can see me running the docker logs command several times over the course of about ~3 mins and getting more and more output each time until it is finally stood up and running!
MyUser:~ myuser$ docker logs f0a177ed739f
Database not initialized. Initializing database.
Starting tnslsnr
MyUser:~ myuser$ docker logs f0a177ed739f
Database not initialized. Initializing database.
Starting tnslsnr
Copying database files
1% complete
3% complete
11% complete
MyUser:~ myuser$ docker logs f0a177ed739f
Database not initialized. Initializing database.
Starting tnslsnr
Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
MyUser:~ myuser$ docker logs f0a177ed739f
Database not initialized. Initializing database.
Starting tnslsnr
Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/xe/xe.log" for further details.
Configuring Apex console
Database initialized. Please visit http://#containeer:8080/em http://#containeer:8080/apex for extra configuration if needed
Starting web management console
PL/SQL procedure successfully completed.
Starting import from '/docker-entrypoint-initdb.d':
found file /docker-entrypoint-initdb.d//docker-entrypoint-initdb.d/*
[IMPORT] /entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
Import finished
Database ready to use. Enjoy! ;)
I can then use a tool like SQLDeveloper to connect to localhost:1521 and create tables, types, etc. So far so good!
However, the instant I kill this container (docker stop and docker rm), all the changes I've made to it get lost! In other words, the next time I run the container (with the exact same docker run command), it takes yet another 3 - 4 mins to initialize, and then all of my changes (table creates, etc.) from the last session are now gone!
Is there a way to tell Docker (maybe as an added arg to the docker run command) to store all the data somewhere on my host/local file system? For example, can I make a "data dir" under ~/myappdb/data and then tell Docker and/or the Oracle DB living inside the container to store all of its data to ~/myappdb/data, so that each time I kill + restart the container my data is persisted?