Home > Enterprise >  Oracle xe 11g in docker, users created are lost after restarting docker on ubuntu
Oracle xe 11g in docker, users created are lost after restarting docker on ubuntu

Time:03-31

I have installed docker on Ubuntu 21.10 and following the official instructions I pulled oracle 11g xe image:

docker pull oracleinanutshell/oracle-xe-11g

Then I started the image:

docker run -d -p 49161:1521 -p 8080:8080 oracleinanutshell/oracle-xe-11g

and using the Oracle SQL Developer I connected as SYSTEM and created a standard user, granting the appropriate privileges (create/delete tables, sequences etc).

Then I connected as that standard user and started creating and populating some tables.

But when stopping the docker image and restarting it, the user and all the tables were lost. What could be done to resolve this issue?

Thanks a lot!

CodePudding user response:

You need to create a volume in order to keep persistent data. Moreover, once you start to deal with those kind of things. It is better to deal using docker compose.

Option 1 using docker:

First create the volume:

docker volume create db-vol

Then use this command in order to attach the volumen where the data is stored:

docker run -d -p 49161:1521 -p 8080:8080 -v db-vol:/opt/oracle/oradata oracleinanutshell/oracle-xe-11g

Option 2 using docker compose:

version: '3'

services: 
  oracle-db:
    image: oracleinanutshell/oracle-xe-11g:latest
    ports:
      - 1521:1521
      - 5500:5500
    volumes:
      - db-vol:/opt/oracle/oradata
volumes:
 db-vol:

Please, find the theory of the concepts needed here:

https://docs.docker.com/storage/volumes/

https://hub.docker.com/r/oracleinanutshell/oracle-xe-11g

  • Related