Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/daggerok/oracle
Oracle Database automation build for docker hub
https://github.com/daggerok/oracle
docker docker-image dockerhub dockerhub-image oracle oracle-11g oracle-database oracle-db
Last synced: 28 days ago
JSON representation
Oracle Database automation build for docker hub
- Host: GitHub
- URL: https://github.com/daggerok/oracle
- Owner: daggerok
- License: mit
- Created: 2018-04-02T16:31:00.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-02T22:40:39.000Z (over 6 years ago)
- Last Synced: 2024-11-11T15:38:37.123Z (3 months ago)
- Topics: docker, docker-image, dockerhub, dockerhub-image, oracle, oracle-11g, oracle-database, oracle-db
- Language: Dockerfile
- Homepage: https://hub.docker.com/r/daggerok/oracle
- Size: 4.98 MB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
= Oracle Database image:https://travis-ci.org/daggerok/oracle.svg?branch=master["Build Status", link="https://travis-ci.org/daggerok/oracle"]
Automation build for docker hub_Oracle XE for rapid development_
- `daggerok/oracle-xe`
_Oracle 11.2.0.2-xe Prebuilt DB (no volumes to commit and push containers)_
- `daggerok/oracle:prebuiltdb`
_Oracle Database 11g Release 2 Express Edition: 11.2.0.2-xe_
- `daggerok/oracle:xe`
- `daggerok/oracle:latest`
- `daggerok/oracle:12.1.0.2`
- `daggerok/oracle:12.1.0.2-xe`_Oracle Database 12c Release 1 Standard Edition (SE2): 12.1.0.2-se_
- `daggerok/oracle:12.1.0.2-se2`
- `daggerok/oracle:12.1.0.2-se`
- `daggerok/oracle:se2`
- `daggerok/oracle:se`
- `daggerok/oracle`NOTE: you can build and prepare same image by yourselves. link:https://github.com/oracle/docker-images/tree/master/OracleDatabase/SingleInstance[see details]
== 11.2.0.2 XE for rapid development
.usage
[source,bash]
----
docker container run \
--shm-size=1g \
-p 8080:8080 -p 1521:1521 \
-it --name oracle-xe \
daggerok/oracle-xe
----NOTE: prebuilt `SYSTEM` username and `password` password.
== 11.2.0.2 XE Prebuilt DB
_Sometimes we wanna prepare our own Oracle Database with specific configurations or with some tests data included.
But due to default Oracle Docker image
link:https://github.com/oracle/docker-images/blob/f847a255a384fd78b187fb0ae7aecee528c36af5/OracleDatabase/SingleInstance/dockerfiles/11.2.0.2/Dockerfile.xe#L81[VOLUME instructions]
we link:https://github.com/oracle/docker-images/issues/269[cannot just commit our container] and reuse it later.
To fix that issue, I have prepared something for you :)_TIP: Here a guide how you can use `daggerok/oracle:prebuiltdb` base image to create and quickly run your own reusable
containers.pull latest prepuiltdb image
[source,bash]
----
docker pull daggerok/oracle:prebuiltdb
----.start container with needed configurations
[source,bash]
----
docker container run \
--shm-size=1g \
-p 8080:8080 -p 1521:1521 \
-e ORACLE_PWD=password \
-it --name oracle-xe \
daggerok/oracle:prebuiltdb
----.wait until oracle database will be ready and gracefully stop oracle-xe container
[source,bash]
----
docker container stop oracle-xe
----.commit container as an reusable image
[source,bash]
----
docker commit \
-a 'Maksim Kostromin ' \
-m 'Oracle XE with credentials SYSTEM / password' \
oracle-xe daggerok/oracle-xe:latest
----.publish image to docker hub
[source,bash]
----
docker push daggerok/oracle-xe:latest
----.now you can re-use it without additional configurations, justl ike so:
[source,bash]
----
docker container run \
--shm-size=1g \
-p 8080:8080 -p 1521:1521 \
-it --name oracle-xe \
daggerok/oracle-xe
----== 11.2.0.2 XE
.usage (docker)
[sources,bash]
----
docker run -d --rm \
--name oracle-xe \
--shm-size=1g \
-p 1521:1521 \
-e ORACLE_PWD=password \
daggerok/oracle:11.2.0.2-xe
# daggerok/oracle:11.2.0.2
# daggerok/oracle:xe
# daggerok/oracleParameters:
--name The name of the container (default: auto generated)
--shm-size Amount of Linux shared memory
-p The port mapping of the host port to the container port.
Two ports are exposed: 1521 (Oracle Listener), 8080 (APEX)
-e ORACLE_PWD The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated)-v /u01/app/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.-v /u01/app/oracle/scripts/startup | /docker-entrypoint-initdb.d
-v /u01/app/oracle/scripts/setup | /docker-entrypoint-initdb.dOptional: A volume with custom scripts to be run after database startup.
For further details see the "Running scripts after setup and on startup" section below.
----.docker-compose usage (simple)
[sources,yaml]
----
version: '2.1'services:
oracle-xe:
image: daggerok/oracle
shm_size: 1g
environment:
ORACLE_PWD: password
APEX_PORT: 8080
ports:
- '1521:1521'
- '8080:8080'
networks: [backing-services]
healthcheck:
test: curl -uSYSTEM:$$ORACLE_PWD -v http://127.0.0.1:$$APEX_PORT//apex/
timeout: 2s
retries: 100networks:
backing-services:
driver: bridge
----.docker-compose usage (advanced)
[sources,yaml]
----
version: "2.1"services:
oracle-xe:
image: daggerok/oracle:11.2.0.2-xe
shm_size: 1g
environment:
ORACLE_PWD: password
ports:
- "1521:1521"
- "8080:8080"
volumes:
- "oracle-xe-data:/u01/app/oracle/oradata"
- "./db-startup-migration-scripts:/u01/app/oracle/scripts/startup"
- "./db-setup-migration-scripts:/docker-entrypoint-initdb.d/setup"
networks: [backing-services]
restart: unless-stoppedvolumes:
oracle-xe-data: {}networks:
backing-services:
driver: bridge
----.Running scripts after setup and on startup. Example mounts the local directory `./migrations` to `/opt/oracle/migration-scripts` which is then searched for custom startup scripts:
[sources,bash]
----
docker run --rm --name oracle-xe \
-p 1521:1521 \
-v $PWD/migrations:/docker-entrypoint-initdb.d/startup \
-v /path/to/oradata:/u01/app/oracle/oradata \
daggerok/oracle:xe
----== 12.1.0.2 SE (WIP)
.usage (docker)
[source,bash]
----
docker run -d --rm --name oracle-se \
--shm-size=1g \
-p 1521:1521 \
-p 5500:5500 \
-e ORACLE_SID=ORCLCDB \
-e ORACLE_PWD=password \
-e ORACLE_PDB=ORCLPDB1 \
-e ORACLE_CHARACTERSET=AL32UTF8 \
daggerok/oracle:12.1.0.2-se2
# daggerok/oracle:12.1.0.2-se
# daggerok/oracleParameters:
--name The name of the container (default: auto generated)
--shm-size Amount of Linux shared memory
-p The port mapping of the host port to the container port.
Two ports are exposed: 1521 (Oracle Listener), 5500 (OEM Express)-e ORACLE_SID The Oracle Database SID that should be used (default: ORCLCDB) The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated)
-e ORACLE_PWD The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated)
-e ORACLE_PDB The Oracle Database PDB name that should be used (default: ORCLPDB1)
-e ORACLE_CHARACTERSET
The character set to use when creating the database (default: AL32UTF8)-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.-v /opt/oracle/scripts/startup | /docker-entrypoint-initdb.d
-v /opt/oracle/scripts/setup | /docker-entrypoint-initdb.dOptional: A volume with custom scripts to be run after database startup.
For further details see the "Running scripts after setup and on startup" section below.
----.docker-compose usage (simple)
[source,yml]
----
version: "2.1"services:
oracle-se:
image: daggerok/oracle
shm_size: 1g
environment:
ORACLE_PWD: password
ports: ["1521:1521"]
networks: [backing-services]
#healthcheck:
# test: curl -uSYSTEM:$$ORACLE_PWD -v http://127.0.0.1:8080//apex/
# interval: 15s
# timeout: 2s
# retries: 22networks:
backing-services:
driver: bridge
----.docker-compose usage (advanced)
[source,yaml]
----
version: "2.1"services:
oracle-se2:
image: daggerok/oracle:12.1.0.2-se2
shm_size: 1g
environment:
ORACLE_SID: xe
ORACLE_PWD: password
ports:
- "1521:1521"
- "5500:5500"
volumes:
- "oracle-se2-data:/opt/oracle/oradata"
- "./db-startup-migration-scripts:/opt/oracle/scripts/startup"
- "./db-setup-migration-scripts:/docker-entrypoint-initdb.d/setup"
networks: [backing-services]
restart: unless-stoppedvolumes:
oracle-se2-data: {}networks:
backing-services:
driver: bridge
----.Running scripts after setup and on startup. Example mounts the local directory `./migrations` to `/opt/oracle/migration-scripts` which is then searched for custom startup scripts:
[source,bash]
----
docker run --rm --name oracle-se \
-p 1521:1521 \
-v $PWD/migrations:/opt/oracle/scripts/startup \
-v /home/oracle/oradata:/opt/oracle/oradata \
daggerok/oracle:12.1.0.2-se2
----== sqlplus
.sqlplus usage
[source,bash]
----
sqlplus sys/@//localhost:1521/ as sysdba
sqlplus system/@//localhost:1521/
sqlplus pdbadmin/@//localhost:1521/
----.sqlplus Mac OS X installation
[source,bash]
----
wget https://github.com/daggerok/oracle/releases/download/oracle/sqlplus-macos.x64-12.2.0.1.0-2.zip
unzip sqlplus-macos.x64-12.2.0.1.0-2.zip
export PATH=$PWD/sqlplus:$PATH
sqlplus -HV
----.sqlplus connection and usage
[source,bash]
----
# docker run ... -e ORACLE_PWD=password ... daggerok/oracle:11.2.0.2-xesqlplus system/password@//0.0.0.0/XE
SQL*Plus: Release 12.2.0.1.0 Production on Tue Apr 24 21:38:50 2018
Copyright (c) 1982, 2017, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit ProductionSQL> select * from dual;
SQL> ...
SQL> quit
Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
----== migratioons
The docker images can be configured to run scripts after setup and on startup.
Currently sh and sql extensions are supported.
For post-setup scripts just mount the volume /opt/oracle/scripts/setup or extend the image to include scripts in this directory.
For post-startup scripts just mount the volume /opt/oracle/scripts/startup or extend the image to include scripts in this directory.
Both of those locations are also represented under the symbolic link /docker-entrypoint-initdb.d.
This is done to provide synergy with other database Docker images. The user is free to decide whether he wants to put his setup and startup scripts under /opt/oracle/scripts or /docker-entrypoint-initdb.d.After the database is setup and/or started the scripts in those folders will be executed against the database in the container.
SQL scripts will be executed as sysdba, shell scripts will be executed as the current user.
To ensure proper order it is recommended to prefix your scripts with a number.
For example, in Flyway-style:- V201711031__app_v1_initial_DDL.sql
- V201711032__app_v1_initial_DML.sql
- V201804021__app_v2_migration_scripts.sql
- ...Note: The startup scripts will also be executed after the first time database setup is complete.
=== apply sql migrations manually using sqlplus
_required running oracle in docker, sqlplus installed, bash / cygwin shell_
.try prepared sample with tablespace / user / DDL:
[source,bash]
----
# run oracle for example with ORACLE_PWD: password
# docker run ... -e ORACLE_PWD=password ... daggerok/oracle:11.2.0.2-xewget https://github.com/daggerok/oracle/releases/download/oracle/sqlplus-sample.zip
unzip -d /tmp sqlplus-sample.zip
bash /tmp/sqlplus-sample/sqlplus-cmd.bash
# verify that `my_app` username / password schema should contains groups and users tables...
----