|
1 | 1 | # oci-oracle-xe
|
2 | 2 | Oracle Database Express Edition Container / Docker images.
|
3 | 3 |
|
4 |
| -The images are compatible with `podman` and `docker`. |
5 |
| -You can use `podman` or `docker` interchangeably. |
| 4 | +**The images are compatible with `podman` and `docker`. You can use `podman` or `docker` interchangeably.** |
6 | 5 |
|
7 |
| -## Image flavors |
| 6 | +# Supported tags and respective `Dockerfile` links |
8 | 7 |
|
9 |
| -| Flavor | Description | Use cases | |
10 |
| -| ------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | |
11 |
| -| 11.2.0.2-slim | An image focussed on smallest possible image size sacrificing on additional functionality. | Best for where small images sizes are important but advanced functionality of Oracle Database is not needed. | |
12 |
| -| 11.2.0.2 | A well-balanced image between image size and functionality. Recommended for most use cases. | Recommended for most use cases. | |
13 |
| -| 11.2.0.2-full | An image containing all functionality as provided by the Oracle Database installation. | Best for extensions or customizations. | |
| 8 | +* [`18.4.0`, `18`, `latest`](https://github.com/gvenzl/oci-oracle-xe/blob/main/Dockerfile.1840) |
| 9 | +* [`18.4.0-full`, `18-full`, `full`](https://github.com/gvenzl/oci-oracle-xe/blob/main/Dockerfile.1840) |
| 10 | +* [`11.2.0.2`, `11`](https://github.com/gvenzl/oci-oracle-xe/blob/main/Dockerfile.11202) |
| 11 | +* [`11.2.0.2-slim`, `11-slim`](https://github.com/gvenzl/oci-oracle-xe/blob/main/Dockerfile.11202) |
| 12 | +* [`11.2.0.2-full`, `11-full`](https://github.com/gvenzl/oci-oracle-xe/blob/main/Dockerfile.11202) |
14 | 13 |
|
15 |
| -For more information, see [Image flavor details](#image-flavor-details). |
| 14 | +# Quick Start |
16 | 15 |
|
17 |
| -## Quick start |
| 16 | +Run a new database container: |
18 | 17 |
|
19 |
| -### Reset passwords |
| 18 | +```shell |
| 19 | +docker run -d -p 1521:1521 -e ORACLE_PASSWORD=<your password> gvenzl/oracle-xe |
20 | 20 | ```
|
21 |
| -docker exec <image name|id> resetPassword <your password> |
| 21 | + |
| 22 | +Run a new persistent database container: |
| 23 | + |
| 24 | +```shell |
| 25 | +docker run -d -p 1521:1521 -e ORACLE_PASSWORD=<your password> -v oracle-volume:/opt/oracle/oradata gvenzl/oracle-xe |
| 26 | +``` |
| 27 | + |
| 28 | +Run a new database container with OEM Express expose: |
| 29 | + |
| 30 | +```shell |
| 31 | +docker run -d -p 1521:1521 -e ORACLE_PASSWORD=<your password> -p 5500:5500 gvenzl/oracle-xe |
| 32 | +``` |
| 33 | + |
| 34 | +Reset database `SYS` and `SYSTEM` passwords: |
| 35 | + |
| 36 | +```shell |
| 37 | +docker exec <container name|id> resetPassword <your password> |
| 38 | +``` |
| 39 | + |
| 40 | +# How to use this image |
| 41 | + |
| 42 | +## Subtle differences between versions |
| 43 | + |
| 44 | +The 11gR2 (11.2.0.2) Oracle Database version stores the database data files under `/u01/app/oracle/oradata/XE`. |
| 45 | +**A volume for 11gR2 has to be pointed at `/u01/app/oradata`!** |
| 46 | + |
| 47 | +## Environment variables |
| 48 | + |
| 49 | +### `ORACLE_PASSWORD` |
| 50 | +This variable is mandatory for the first container startup and specifies the password for the Oracle Database `SYS` and `SYSTEM` users. |
| 51 | + |
| 52 | +### `ORACLE_RANDOM_PASSWORD` |
| 53 | +This is an optional variable. Set this variable to a non-empty value, like `yes`, to generate a random initial password for the `SYS` and `SYSTEM` users. The generated password will be printed to stdout (`ORACLE PASSWORD FOR SYS AND SYSTEM: ...`). |
| 54 | + |
| 55 | +## Container secrets |
| 56 | + |
| 57 | +As an alternative to passing sensitive information via environment variables, `_FILE` may be appended to some of the previously listed environment variables, causing the initialization script to load the values for those variables from files present in the container. In particular, this can be used to load passwords from Container/Docker secrets stored in `/run/secrets/<secret_name>` files. For example: |
| 58 | + |
| 59 | +```shell |
| 60 | +docker run --name some-oracle -e ORACLE_PASSWORD_FILE=/run/secrets/oracle-passwd -d gvenzl/oracle-xe |
22 | 61 | ```
|
23 | 62 |
|
24 |
| -## Image flavor details |
| 63 | +Currently, this is only supported for `ORACLE_PASSWORD`. |
| 64 | + |
| 65 | +## Initialization scripts |
| 66 | +If you would like to perform additional initialization of the database running in a container, you can add one or more `*.sql`, `*.sql.gz`, `*.sql.zip` or `*.sh` files under `/container-entrypoint-initdb.d` (creating the directory if necessary). After the database setup is completed, these files will be executed automatically in alphabetical order. |
| 67 | + |
| 68 | +The `*.sql`, `*.sql.gz` and `*.sql.zip` files will be executed in Sql*Plus as the `SYS` user connected to the Oracle instance (`XE`). Compressed files will be uncompressed on the fly, allowing for e.g. bigger data loading scripts to save space. |
| 69 | + |
| 70 | +Executable `*.sh` files will be run in a new shell process while non-executable `*.sh` files (files that do not have the Linux e`x`ecutable permission set) will be sourced into the current shell process. The main difference between these methods is that sourced shell scripts can influence the environment of the current process and should generally be avoided. However, sourcing scripts allows for execution of these scripts even if the executable flag is not set for the files containing them. This basically avoids the "why did my script not get executed" confusion. |
| 71 | + |
| 72 | +***Note:*** scripts in `/container-entrypoint-initdb.d` are only run the first time the database is initialized; any pre-existing database will be left untouched on container startup. |
| 73 | + |
| 74 | +***Note:*** you can also put files under the `/docker-entrypoint-initdb.d` directory. This is kept for backwards compatibility with other widely used container images but should generally be avoided. Do not put files under `/container-entrypoint-initdb.d` **and** `/docker-entrypoint-initdb.d` as this would cause the same files to be executed twice! |
| 75 | + |
| 76 | +***Warning:*** if a command within the sourced `/container-entrypoint-initdb.d` scripts fails, it will cause the main entrypoint script to exit and stop the container. It also may leave the database in an incomplete initialized state. Make sure that shell scripts handle error situations gracefully and ideally do not source them! |
| 77 | + |
| 78 | +***Warning:*** do not exit executable `/container-entrypoint-initdb.d` scripts with a non-zero value (using e.g. `exit 1;`) unless it is desired for a container to be stopped! A non-zero return value will tell the main entrypoint script that something has gone wrong and that the container should be stopped. |
| 79 | + |
| 80 | +### Example |
| 81 | + |
| 82 | +The following example installs the [countries, cities and currencies sample data set](https://github.com/gvenzl/sample-data/tree/master/countries-cities-currencies) under a new user `TEST` into the database: |
| 83 | + |
| 84 | +```shell |
| 85 | +[gvenzl@localhost init_scripts]$ pwd |
| 86 | +/home/gvenzl/init_scripts |
| 87 | + |
| 88 | +[gvenzl@localhost init_scripts]$ ls -al |
| 89 | +total 12 |
| 90 | +drwxrwxr-x 2 gvenzl gvenzl 61 Mar 7 11:51 . |
| 91 | +drwx------. 19 gvenzl gvenzl 4096 Mar 7 11:51 .. |
| 92 | +-rw-rw-r-- 1 gvenzl gvenzl 134 Mar 7 11:50 1_create_user.sql |
| 93 | +-rwxrwxr-x 1 gvenzl gvenzl 164 Mar 7 11:51 2_create_data_model.sh |
| 94 | + |
| 95 | +[gvenzl@localhost init_scripts]$ cat 1_create_user.sql |
| 96 | +ALTER SESSION SET CONTAINER=XEPDB1; |
| 97 | + |
| 98 | +CREATE USER TEST IDENTIFIED BY test QUOTA UNLIMITED ON USERS; |
| 99 | + |
| 100 | +GRANT CONNECT, RESOURCE TO TEST; |
| 101 | + |
| 102 | +[gvenzl@localhost init_scripts]$ cat 2_create_data_model.sh |
| 103 | +curl -LJO https://raw.githubusercontent.com/gvenzl/sample-data/master/countries-cities-currencies/install.sql |
| 104 | + |
| 105 | +sqlplus -s test/test@//localhost/XEPDB1 @install.sql |
| 106 | + |
| 107 | +rm install.sql |
| 108 | + |
| 109 | +``` |
| 110 | + |
| 111 | +As the execution happens in alphabetical order, numbering the files will guarantee the execution order. A new container started up with `/home/gvenzl/init_scripts` pointing to `/container-entrypoint-initdb.d` will then execute the files above: |
| 112 | + |
| 113 | +```shell |
| 114 | +podman run --name test \ |
| 115 | +> -p 1521:1521 \ |
| 116 | +> -e ORACLE_RANDOM_PASSWORD="y" \ |
| 117 | +> -v /home/gvenzl/init_scripts:/container-entrypoint-initdb.d \ |
| 118 | +> gvenzl/oracle-xe:18.4.0-full |
| 119 | +CONTAINER: starting up... |
| 120 | +CONTAINER: first database startup, initializing... |
| 121 | +... |
| 122 | +CONTAINER: Executing user defined scripts... |
| 123 | +CONTAINER: running /container-entrypoint-initdb.d/1_create_user.sql ... |
25 | 124 |
|
26 |
| -There are three flavors of the image: |
27 |
| - * FULL (`-full` tag appended) |
28 |
| - * NORMAL (no tag appended) |
29 |
| - * SLIM (`-slim` tag appended) |
| 125 | +Session altered. |
30 | 126 |
|
31 |
| -### Full image flavor |
| 127 | + |
| 128 | +User created. |
| 129 | + |
| 130 | + |
| 131 | +Grant succeeded. |
| 132 | + |
| 133 | +CONTAINER: DONE: running /container-entrypoint-initdb.d/1_create_user.sql |
| 134 | + |
| 135 | +CONTAINER: running /container-entrypoint-initdb.d/2_create_data_model.sh ... |
| 136 | + % Total % Received % Xferd Average Speed Time Time Time Current |
| 137 | + Dload Upload Total Spent Left Speed |
| 138 | +100 115k 100 115k 0 0 460k 0 --:--:-- --:--:-- --:--:-- 460k |
| 139 | + |
| 140 | +Table created. |
| 141 | +... |
| 142 | +Table provided actual |
| 143 | +-------------------- ---------- ---------- |
| 144 | +regions 7 7 |
| 145 | +countries 196 196 |
| 146 | +cities 204 204 |
| 147 | +currencies 146 146 |
| 148 | +currencies_countries 203 203 |
| 149 | + |
| 150 | + |
| 151 | +Thank you! |
| 152 | +-------------------------------------------------------------------------------- |
| 153 | +The installation is finished, please check the verification output above! |
| 154 | +If the 'provided' and 'actual' row counts match, the installation was successful |
| 155 | +. |
| 156 | + |
| 157 | +If the row counts do not match, please check the above output for error messages |
| 158 | +. |
| 159 | + |
| 160 | + |
| 161 | +CONTAINER: DONE: running /container-entrypoint-initdb.d/2_create_data_model.sh |
| 162 | + |
| 163 | +CONTAINER: DONE: Executing user defined scripts. |
| 164 | + |
| 165 | + |
| 166 | +######################### |
| 167 | +DATABASE IS READY TO USE! |
| 168 | +######################### |
| 169 | +... |
| 170 | +``` |
| 171 | + |
| 172 | +As a result, one can then connect to the new schema directly: |
| 173 | + |
| 174 | +```shell |
| 175 | +[gvenzl@localhost init_scripts]$ sql test/test@//localhost/XEPDB1 |
| 176 | + |
| 177 | +SQLcl: Release 20.3 Production on Sun Mar 07 12:05:06 2021 |
| 178 | + |
| 179 | +Copyright (c) 1982, 2021, Oracle. All rights reserved. |
| 180 | + |
| 181 | +Connected to: |
| 182 | +Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production |
| 183 | +Version 18.4.0.0.0 |
| 184 | + |
| 185 | + |
| 186 | +SQL> select * from countries where name = 'Austria'; |
| 187 | + |
| 188 | +COUNTRY_ID COUNTRY_CODE NAME OFFICIAL_NAME POPULATION AREA_SQ_KM LATITUDE LONGITUDE TIMEZONE REGION_ID |
| 189 | +---------- ------------ ------- ------------------- ---------- ---------- -------- --------- ------------- --------- |
| 190 | +AUT AT Austria Republic of Austria 8793000 83871 47.33333 13.33333 Europe/Vienna EU |
| 191 | + |
| 192 | +SQL> |
| 193 | +``` |
| 194 | +
|
| 195 | +## Startup scripts |
| 196 | +
|
| 197 | +If you would like to perform additional action after the database running in a container has been started, you can add one or more `*.sql`, `*.sql.gz`, `*.sql.zip` or `*.sh` files under `/container-entrypoint-startdb.d` (creating the directory if necessary). After the database is up and ready for requests, these files will be executed automatically in alphabetical order. |
| 198 | +
|
| 199 | +The execution order and implications are the same as with the [Initialization scripts](#initialization-scripts) described above. |
| 200 | +
|
| 201 | +***Note:*** you can also put files under the `/docker-entrypoint-startdb.d` directory. This is kept for backwards compatibility with other widely used container images but should generally be avoided. Do not put files under `/container-entrypoint-startdb.d` **and** `/docker-entrypoint-startdb.d` as this would cause the same files to be executed twice! |
| 202 | +
|
| 203 | +***Note:*** if the database inside the container is initialized (started for the first time), startup scripts are executed after the setup scripts. |
| 204 | +
|
| 205 | +***Warning:*** files placed in `/container-entrypoint-startdb.d` are always executed after the database in a container is started, including pre-created databases. Use this mechanism only if you wish to perform a certain task always after the database has been (re)started by the container. |
| 206 | +
|
| 207 | +# Image flavors |
| 208 | +
|
| 209 | +| Flavor | Extension | Description | Use cases | |
| 210 | +| -------| --------- | ------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------| |
| 211 | +| Slim | `-slim` | An image focussed on smallest possible image size instead of additional functionality. | Wherever small images sizes are important but advanced functionality of Oracle Database is not needed. | |
| 212 | +| Normal | [None] | A well-balanced image between image size and functionality. Recommended for most use cases. | Recommended for most use cases. | |
| 213 | +| Full | `-full` | An image containing all functionality as provided by the Oracle Database installation. | Best for extensions and/or customizations. | |
| 214 | +
|
| 215 | +## Full image flavor |
32 | 216 |
|
33 | 217 | The full image provides an Oracle Database XE installation "as is", meaning as provided by the RPM install file.
|
34 | 218 | A couple of modifications have been performed to make the installation more suitable for running inside a container:
|
35 | 219 |
|
36 |
| -* The `REDO` logs have been relocated into `$ORACLE_BASE/oradata/$ORACLE_SID/` |
37 |
| -* The fast recovery area has been relocated into `$ORACLE_BASE/oradata/$ORACLE_SID/` |
38 | 220 | * `DBMS_XDB.SETLISTENERLOCALACCESS()` has been set to `FALSE`
|
39 | 221 | * An `OPS$ORACLE` externally identified user has been created and granted `CONNECT` and `SELECT_CATALOG_ROLE` (this is used for health check and other operations)
|
40 | 222 |
|
41 |
| -### Normal image flavor |
| 223 | +### 18c specific |
| 224 | +
|
| 225 | +* `LOCAL_LISTENER` is set to `NULL` (18c) |
| 226 | +* `COMMON_USER_PREFIX` is set to `NULL` (18c) |
| 227 | +
|
| 228 | +### 11g R2 specific |
| 229 | +
|
| 230 | +* The `REDO` logs have been located into `$ORACLE_BASE/oradata/$ORACLE_SID/` (11gR2 image) |
| 231 | +* The fast recovery area has been removed (11gR2 images) |
| 232 | +
|
| 233 | +## Normal image flavor |
42 | 234 |
|
43 | 235 | The normal image has all customizations that the full image has.
|
44 | 236 | Additionally, it also includes the following changes:
|
45 | 237 |
|
46 |
| -#### Database components |
47 |
| -* Oracle APEX has been removed (you can download and install the latest and greatest from [apex.oracle.com](https://apex.oracle.com)) |
| 238 | +### Database components |
| 239 | +* Oracle APEX has been removed (you can download and install the latest and greatest from [apex.oracle.com](https://apex.oracle.com), 11gR2 image) |
48 | 240 | * The `HR` schema and folder have been removed
|
49 |
| -* The jdbc drivers have been removed |
50 | 241 |
|
51 |
| -#### Operating system |
| 242 | +### Operating system |
52 | 243 |
|
53 |
| -* The following Linux packages are not installed: `binutils`, `gcc`, `glibc`, `make` |
| 244 | +* The following Linux packages are not installed: `binutils`, `gcc`, `glibc`, `make` (11g R2) |
| 245 | +* The jdbc drivers have been removed (`$ORACLE_HOME/jdbc`, `$ORACLE_HOME/jlib`) |
54 | 246 |
|
55 |
| -#### Data files |
| 247 | +### Data files |
56 | 248 |
|
57 |
| -| Tablespace | Size | Autoextend | Max size | |
58 |
| -| ---------- | -----: | ---------: | ----------- | |
59 |
| -| `REDO` | 20 MB | `N/A` | `N/A` | |
60 |
| -| `TEMP` | 2 MB | 10 MB | `UNLIMITED` | |
61 |
| -| `UNDO` | 10 MB | 10 MB | `UNLIMITED` | |
62 |
| -| `USERS` | 10 MB | 10 MB | `UNLIMITED` | |
| 249 | +| Tablespace | 18c Size | 11g Size | Autoextend | Max size | |
| 250 | +| ---------- | --------:| -------: | ---------: | ----------- | |
| 251 | +| `REDO` | 20 MB | 20 MB | `N/A` | `N/A` | |
| 252 | +| `SYSAUX` | 480 MB (CDB) <br> 342 MB (PDB) | 610 MB | 10 MB | `UNLIMITED` | |
| 253 | +| `SYSTEM` | 353 MB (CDB) <br> 255 MB (PDB) | 353 MB | 10 MB | `UNLIMITED` | |
| 254 | +| `TEMP` | 2 MB (CDB) <br> 2 MB (PDB) | 2 MB | 10 MB | `UNLIMITED` | |
| 255 | +| `UNDO` | 70 MB (CDB) <br> 40 MB (PDB) | 10 MB | 10 MB | `UNLIMITED` | |
| 256 | +| `USERS` | 10 MB | 10 MB | 10 MB | `UNLIMITED` | |
63 | 257 |
|
64 |
| -#### Others |
| 258 | +### Others |
65 | 259 |
|
66 | 260 | * The `DEFAULT` profile has the following set:
|
67 | 261 | * `FAILED_LOGIN_ATTEMPTS=UNLIMITED`
|
|
0 commit comments