├── .github └── FUNDING.yml ├── .vscode └── settings.json └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: martindsouza 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-oracle-setup 2 | 3 | This document will keep an up to date version of my personal Oracle dockerized development environment. The main goal is to have one Oracle database with multiple versions of APEX installed. 4 | 5 | This is achieved using Oracle 12c containers (not to be confused with Docker containers). If you're not too familiar with Oracle 12c containers I highly recommend reading [this](http://www.oracle.com/technetwork/articles/database/multitenant-part1-pdbs-2193987.html) article which covers Container Databases (CDB) and Pluggable Databases (PDB). 6 | 7 | 8 | 9 | - [Known Issues and Future Improvements](#known-issues-and-future-improvements) 10 | - [References](#references) 11 | - [Background](#background) 12 | - [Port Mapping](#port-mapping) 13 | - [Passwords](#passwords) 14 | - [Download Files](#download-files) 15 | - [Laptop Folder Structure](#laptop-folder-structure) 16 | - [Oracle Container Registry Setup](#oracle-container-registry-setup) 17 | - [Setup](#setup) 18 | - [Directory structure](#directory-structure) 19 | - [Docker Network](#docker-network) 20 | - [Docker Images](#docker-images) 21 | - [Get Oracle Image](#get-oracle-image) 22 | - [ORDS](#ords) 23 | - [Docker Image Confirmation](#docker-image-confirmation) 24 | - [Docker Containers](#docker-containers) 25 | - [Oracle Container](#oracle-container) 26 | - [Oracle CDB and PDB Setup](#oracle-cdb-and-pdb-setup) 27 | - [CDB Setup](#cdb-setup) 28 | - [PDB Setup](#pdb-setup) 29 | - [Create PDBs](#create-pdbs) 30 | - [APEX 18.1.0 Install](#apex-1810-install) 31 | - [APEX 5.1.4 Install](#apex-514-install) 32 | - [APEX 5.0.4 Install](#apex-504-install) 33 | - [ORDS Containers](#ords-containers) 34 | - [ORDS 18.1.0](#ords-1810) 35 | - [ORDS 5.1.4](#ords-514) 36 | - [ORDS 5.0.4](#ords-504) 37 | - [ORDS Container Wrappup](#ords-container-wrappup) 38 | - [Useful Commands](#useful-commands) 39 | - [Quick Start](#quick-start) 40 | - [Docker](#docker) 41 | - [Oracle](#oracle) 42 | - [Connection Strings](#connection-strings) 43 | - [DBA](#dba) 44 | - [Sample Data](#sample-data) 45 | - [Common Problems](#common-problems) 46 | - [Oracle Docker Container](#oracle-docker-container) 47 | - [Issues writing to `/ORCL` folder](#issues-writing-to-orcl-folder) 48 | 49 | 50 | 51 | 52 | 53 | ## Known Issues and Future Improvements 54 | 55 | - Use Oracle's official ORDS image from the Container Registry 56 | 57 | ## References 58 | 59 | The following articles and all my scripts are a result of a combination of the code found in the links. 60 | 61 | - [APEX and ORDS up and running in....2 steps!](http://joelkallman.blogspot.ca/2017/05/apex-and-ords-up-and-running-in2-steps.html) by [Joel Kallman](https://twitter.com/joelkallman) 62 | - [Dockerize your APEX development environment](http://roelhartman.blogspot.ca/2017/10/dockerize-your-apex-development.html) by [Roel Hartman](https://twitter.com/RoelH) 63 | - [Oracle Database 12c now available on Docker](https://sqlmaria.com/2017/04/27/oracle-database-12c-now-available-on-docker/) by [Maria Colgan](https://twitter.com/sqlmaria) 64 | 65 | ## Background 66 | 67 | - All my scripts are Linux / MacOS focused. If you use a Windows machine you'll need to translate 68 | - I specifically made reference to "your laptop" to emphasize what was run "on your machine" vs "in a docker container" 69 | - I use [SQLcl](http://www.oracle.com/technetwork/developer-tools/sqlcl/overview/index.html) instead of SQLplus on my laptop. I've also renamed the default command `sql` to `sqlcl`. You can use `sqlplus` or follow my [sqlcl install instructions](http://www.talkapex.com/2015/04/installing-sqlcl/). 70 | 71 | ### Port Mapping 72 | 73 | The following port mapping will be used. To help remember the DB version, the database port ends in its version number `122` for `12.2`. Likewise, the ORDS ports end in the APEX version they link to ex: `514` for `5.1.4`, `1810` for `18.1.0`. 74 | 75 | Container | Container Port | Laptop Port | Description 76 | --- | --- | --- | --- 77 | `oracle` | `1521` | `32122` | TNS listener for Oracle 12.2 78 | `ords-504` | `8080` | `32504` | ORDS for APEX 5.0.4 79 | `ords-514` | `8080` | `32514` | ORDS for APEX 5.1.4 80 | `ords-1810` | `8080` | `31810` | ORDS for APEX 18.1.0 81 | 82 | ### Passwords 83 | 84 | Since this setup is for my own development environment (and to keep things simple) the following passwords will be used for the setup 85 | 86 | Container | Username | Password | Description 87 | --- | --- | --- | --- 88 | `oracle` | `sys` | `Oradoc_db1` | All sys passwords for all PDBs will be the same 89 | `oracle` | `admin` | `Oradoc_db1` | Workspace `Internal` for all APEX admin 90 | 91 | ### Download Files 92 | 93 | Due to licensing restrictions I can't host/provide these files in Github or elsewhere. As such you'll need to download them manually. Download the following files and store them in your `~/Downloads` folder: 94 | 95 | Application | Description 96 | --- | --- 97 | [APEX 18.1](http://www.oracle.com/technetwork/developer-tools/apex/downloads/index.html) | At the time of writing, 18.1 is the most recent version. 98 | [APEX 5.1.4](http://www.oracle.com/technetwork/developer-tools/apex/downloads/apex-51-archive-3661848.html) | Find it in the APEX archive page. 99 | [APEX 5.0.4](http://www.oracle.com/technetwork/developer-tools/apex/downloads/apex-5-archive-2606313.html) | Find it in the APEX archive page. 100 | [ORDS 18.1.1](http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads) | At the time of writing ORDS 18.1.1 was the most recent version. 101 | 102 | 103 | ### Laptop Folder Structure 104 | 105 | We'll assume that the folder structure below is setup. A script is provided later on to create this. 106 | 107 | Path | Description 108 | --- | --- 109 | `~/docker` | root 110 | `~/docker/apex` | APEX installation files and images for each version. 2 versions of APEX are included in this example but more can easily be added 111 | `~/docker/apex/18.1.0` | APEX 18.1.0 installation files 112 | `~/docker/apex/5.1.4` | APEX 5.1.4 installation files 113 | `~/docker/apex/5.0.4` | APEX 5.0.4 installation files 114 | `~/docker/oracle` | Oracle 12.2 data files 115 | `~/docker/ords` | ORDS Dockerfile (to build ORDS image) 116 | `~/docker/tmp` | Temp folder 117 | 118 | ### Oracle Container Registry Setup 119 | 120 | To work with Oracle's licensing for docker (and to avoid manually building images yourself) you'll need to login to the [container-registry.oracle.com](https://container-registry.oracle.com) and use your Oracle Technology Network (OTN) login and register. 121 | 122 | One logged in go to `Database > Enterprise` and read the license agreement. If you agree to the Terms and Conditions click the Accept button. 123 | 124 | 125 | ## Setup 126 | 127 | The following steps only ever need to be done once. 128 | 129 | ### Directory structure 130 | 131 | The following script will create the directory structure as mentioned above 132 | 133 | ```bash 134 | mkdir ~/docker 135 | cd ~/docker 136 | mkdir apex 137 | mkdir oracle 138 | mkdir ords 139 | ``` 140 | 141 | Copy the files from the `~/Downloads` folder to the appropriate `~/docker` folder and unzip 142 | 143 | ```bash 144 | # *** APEX *** 145 | cd ~/docker/apex 146 | cp ~/Downloads/apex*.zip . 147 | 148 | # Unzip 149 | unzip apex_18.1.zip 150 | mv apex 18.1.0 151 | 152 | unzip apex_5.1.4.zip 153 | mv apex 5.1.4 154 | 155 | unzip apex_5.0.4.zip 156 | mv apex 5.0.4 157 | 158 | # ORDS will be dealt in the ORDS image section 159 | ``` 160 | 161 | ### Docker Network 162 | 163 | In order for the containers to “talk” to each other we need to setup a Docker network and associate all the containers on this network. Containers can reference each other by their respective container names. When referencing another container on the same Docker network the port used is the container’s native port **not** the mapped port on your laptop. 164 | 165 | ```bash 166 | docker network create oracle_network 167 | # Other docker network commands (don't need to run them as part of install) 168 | # Connect and existing container to a docker network 169 | # docker network connect 170 | # View a network and connected containers 171 | # In this example "oracle_network" is the network we're interested in 172 | docker network inspect oracle_network 173 | ``` 174 | 175 | ### Docker Images 176 | 177 | Two images are required to get the setup working: Oracle and ORDS. 178 | 179 | #### Get Oracle Image 180 | 181 | *If you haven't already done so already read above about the `container-registry.oracle.com`. You won't be able to pull the container until you agree to the Terms and Conditions.* 182 | 183 | ```bash 184 | # *** NOTE: container-register.oracle.com is slow 185 | # Instead you can try the following URLs in its place: 186 | # container-registry-phx.oracle.com 187 | # container-registry-ash.oracle.com 188 | # 189 | # Login to Oracle's container registry 190 | docker login container-registry.oracle.com 191 | 192 | # They're various docker 12c images. To help reduce the number (and size) of images on my laptop I only needed the 12.2 version 193 | # This will take a while to run as the image size is around 3.5 GB 194 | # Note currently the registry server is slow so you may have to wait a while for the image to download 195 | docker pull container-registry.oracle.com/database/enterprise:12.2.0.1 196 | ``` 197 | 198 | #### ORDS 199 | 200 | *Oracle has scripts available to build an ORDS image. At the time of writing (11-Nov-2017) there's an issue with the script ([Issue #646](https://github.com/oracle/docker-images/issues/646)) that prevents me from using it. I suspect that Oracle will include a pre-built image on their container registry in the future so I'll update the section with their image when/if it becomes available. In the mean time the image will be built using another script.* 201 | 202 | **Important:** I've created a separate [ORDS Docker Image](https://github.com/martindsouza/docker-ords) repo. Since it's being actively updated and to avoid duplication of documentation please refer to the repo to build your ORDS Docker image. **Go through it now to create your ORDS Docker image**. 203 | 204 | #### Docker Image Confirmation 205 | 206 | At this point you should see the following (or similar) output when running `docker images` 207 | 208 | ``` 209 | docker images 210 | 211 | REPOSITORY TAG IMAGE ID CREATED SIZE 212 | ords 18.1.1 a735271f7bf5 17 seconds ago 537MB 213 | container-registry.oracle.com/database/enterprise 12.2.0.1 12a359cd0528 2 months ago 3.44GB 214 | ``` 215 | 216 | 217 | ## Docker Containers 218 | 219 | Now that the setup is complete we can create all the Docker containers 220 | 221 | ### Oracle Container 222 | 223 | Adding the `-e TZ` option will set the appropriate timezone for the OS and the database. A full list of timezones can be found [here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). If excluded it will default to UTC. 224 | 225 | ```bash 226 | docker run -d -it \ 227 | --name oracle \ 228 | -p 32122:1521 \ 229 | -e TZ=America/Edmonton \ 230 | --network=oracle_network \ 231 | -v ~/docker/oracle:/ORCL \ 232 | -v ~/docker/apex:/tmp/apex \ 233 | container-registry.oracle.com/database/enterprise:12.2.0.1 234 | 235 | # Running docker ps will result in: 236 | docker ps 237 | 238 | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 239 | 6b4d96d63cf5 container-registry.oracle.com/database/enterprise:12.2.0.1 "/bin/sh -c '/bin/..." 4 seconds ago Up 5 seconds (health: starting) 5500/tcp, 0.0.0.0:32112->1521/tcp oracle 240 | 241 | # More specifically if you need to create a script around this 242 | # docker inspect --format="{{.State.Health.Status}}" oracle 243 | # Will give you precise information about the status 244 | ``` 245 | 246 | You'll need to run `docker ps` several times until the status is `(healthy)`. Before you see `(healthy)`, the status will be `(unhealthy)`. This is normal. You will be able to monitor the `~/docker/oracle` directory increases in size. 247 | 248 | You can follow the install by running `docker logs oracle` 249 | 250 | ### Oracle CDB and PDB Setup 251 | 252 | #### CDB Setup 253 | 254 | Starting in Oracle 12.2 the database should not come pre-installed with APEX. [Joel Kallman](https://twitter.com/joelkallman) wrote an [article](http://joelkallman.blogspot.ca/2016/03/an-important-change-coming-for-oracle.html) about why this. For some reason the container from Oracle comes with APEX 5.0.4 installed in the CDB. It must first be removed. 255 | 256 | ```bash 257 | # On your laptop: 258 | docker exec -it oracle bash -c "source /home/oracle/.bashrc; bash" 259 | 260 | # You should now be in the Oracle Docker container 261 | cd /tmp/apex/5.0.4 262 | 263 | sqlplus sys/Oradoc_db1@localhost/orclcdb.localdomain as sysdba 264 | 265 | @apxremov.sql 266 | -- Exit sqlplus 267 | exit 268 | 269 | # Exit bash 270 | exit 271 | ``` 272 | 273 | #### PDB Setup 274 | 275 | The Oracle container database will come with a default PDB (`ORCLPDB1`). We'll leave it alone and create new PDBs for each version of APEX. 276 | 277 | Note I've included the APEX installs in these sections since they're required for the ORDS containers. 278 | 279 | ##### Create PDBs 280 | 281 | On your laptop connect to the database: `sqlcl sys/Oradoc_db1@localhost:32122:orclcdb as sysdba` 282 | 283 | ```sql 284 | -- Create 18.1.0 PDB 285 | create pluggable database orclpdb1810 admin user pdb_adm identified by Oradoc_db1 286 | file_name_convert=('/u02/app/oracle/oradata/ORCL/pdbseed/','/u02/app/oracle/oradata/ORCL/ORCLPDB1810/'); 287 | 288 | -- Create 5.1.4 PDB 289 | create pluggable database orclpdb514 admin user pdb_adm identified by Oradoc_db1 290 | file_name_convert=('/u02/app/oracle/oradata/ORCL/pdbseed/','/u02/app/oracle/oradata/ORCL/ORCLPDB514/'); 291 | 292 | -- Create 5.0.4 PDB 293 | create pluggable database orclpdb504 admin user pdb_adm identified by Oradoc_db1 294 | file_name_convert=('/u02/app/oracle/oradata/ORCL/pdbseed/','/u02/app/oracle/oradata/ORCL/ORCLPDB504/'); 295 | 296 | -- Running the following query will show the newly created PDBs but they are not open for Read Write: 297 | select vp.name, vp.open_mode 298 | from v$pdbs vp; 299 | 300 | NAME OPEN_MODE 301 | PDB$SEED READ WRITE 302 | ORCLPDB1 READ WRITE 303 | ORCLPDB514 MOUNTED 304 | ORCLPDB504 MOUNTED 305 | ORCLPDB1810 MOUNTED 306 | 307 | -- Open the PDB 308 | alter pluggable database orclpdb1810 open read write; 309 | alter pluggable database orclpdb514 open read write; 310 | alter pluggable database orclpdb504 open read write; 311 | 312 | -- If nothing is changed the PDBs won't be loaded on boot. 313 | -- They're a few ways to do this 314 | -- See for reference https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:9531671900346425939 315 | -- alter pluggable database pdb_name save state; 316 | -- alter pluggable database all save state; 317 | -- alter pluggable database all except pdb$seed open read write 318 | alter pluggable database all save state; 319 | 320 | -- Exit sqlcl 321 | exit 322 | ``` 323 | 324 | ##### APEX 18.1.0 Install 325 | 326 | ```bash 327 | # On your laptop 328 | docker exec -it oracle bash -c "source /home/oracle/.bashrc; bash" 329 | 330 | # You should now be in the Oracle Docker container 331 | cd /tmp/apex/18.1.0 332 | sqlplus sys/Oradoc_db1@localhost/orclpdb1810.localdomain as sysdba 333 | ``` 334 | 335 | ```sql 336 | @apexins.sql SYSAUX SYSAUX TEMP /i/ 337 | 338 | -- APEX REST configuration 339 | @apex_rest_config_core.sql oracle oracle 340 | 341 | -- Required for ORDS install 342 | alter user apex_public_user identified by oracle account unlock; 343 | 344 | -- From Joels blog: http://joelkallman.blogspot.ca/2017/05/apex-and-ords-up-and-running-in2-steps.html 345 | declare 346 | l_acl_path varchar2(4000); 347 | l_apex_schema varchar2(100); 348 | begin 349 | for c1 in (select schema 350 | from sys.dba_registry 351 | where comp_id = 'APEX') loop 352 | l_apex_schema := c1.schema; 353 | end loop; 354 | sys.dbms_network_acl_admin.append_host_ace( 355 | host => '*', 356 | ace => xs$ace_type(privilege_list => xs$name_list('connect'), 357 | principal_name => l_apex_schema, 358 | principal_type => xs_acl.ptype_db)); 359 | commit; 360 | end; 361 | / 362 | 363 | -- Setup APEX Admin password 364 | begin 365 | apex_util.set_security_group_id( 10 ); 366 | apex_util.create_user( 367 | p_user_name => 'ADMIN', 368 | p_email_address => 'martin@talkapex.com', 369 | p_web_password => 'Oradoc_db1', 370 | p_developer_privs => 'ADMIN', 371 | p_change_password_on_first_use => 'N'); 372 | apex_util.set_security_group_id( null ); 373 | commit; 374 | end; 375 | / 376 | -- Exit SQL 377 | exit 378 | ``` 379 | 380 | ```bash 381 | # You can now exit bash on the container 382 | exit 383 | ``` 384 | 385 | ##### APEX 5.1.4 Install 386 | 387 | ```bash 388 | # On your laptop 389 | docker exec -it oracle bash -c "source /home/oracle/.bashrc; bash" 390 | 391 | # You should now be in the Oracle Docker container 392 | cd /tmp/apex/5.1.4 393 | sqlplus sys/Oradoc_db1@localhost/orclpdb514.localdomain as sysdba 394 | ``` 395 | 396 | ```sql 397 | @apexins.sql SYSAUX SYSAUX TEMP /i/ 398 | 399 | -- APEX REST configuration 400 | @apex_rest_config_core.sql oracle oracle 401 | 402 | -- Required for ORDS install 403 | alter user apex_public_user identified by oracle account unlock; 404 | 405 | -- From Joels blog: http://joelkallman.blogspot.ca/2017/05/apex-and-ords-up-and-running-in2-steps.html 406 | declare 407 | l_acl_path varchar2(4000); 408 | l_apex_schema varchar2(100); 409 | begin 410 | for c1 in (select schema 411 | from sys.dba_registry 412 | where comp_id = 'APEX') loop 413 | l_apex_schema := c1.schema; 414 | end loop; 415 | sys.dbms_network_acl_admin.append_host_ace( 416 | host => '*', 417 | ace => xs$ace_type(privilege_list => xs$name_list('connect'), 418 | principal_name => l_apex_schema, 419 | principal_type => xs_acl.ptype_db)); 420 | commit; 421 | end; 422 | / 423 | 424 | -- Setup APEX Admin password 425 | begin 426 | apex_util.set_security_group_id( 10 ); 427 | apex_util.create_user( 428 | p_user_name => 'ADMIN', 429 | p_email_address => 'martin@talkapex.com', 430 | p_web_password => 'Oradoc_db1', 431 | p_developer_privs => 'ADMIN', 432 | p_change_password_on_first_use => 'N'); 433 | apex_util.set_security_group_id( null ); 434 | commit; 435 | end; 436 | / 437 | -- Exit SQL 438 | exit 439 | ``` 440 | 441 | ```bash 442 | # You can now exit bash on the container 443 | exit 444 | ``` 445 | 446 | 447 | ##### APEX 5.0.4 Install 448 | 449 | ```bash 450 | # On your laptop 451 | docker exec -it oracle bash -c "source /home/oracle/.bashrc; bash" 452 | 453 | # You should now be in the Oracle Docker container 454 | cd /tmp/apex/5.0.4 455 | sqlplus sys/Oradoc_db1@localhost/orclpdb504.localdomain as sysdba 456 | ``` 457 | 458 | ```sql 459 | @apexins.sql SYSAUX SYSAUX TEMP /i/ 460 | 461 | -- APEX REST configuration 462 | -- For APEX 5.0.4 I get an error when running the statement below 463 | -- Just login and re-run 464 | @apex_rest_config_core.sql oracle oracle 465 | 466 | -- Required for ORDS install 467 | alter user apex_public_user identified by oracle account unlock; 468 | 469 | -- From Joels blog: http://joelkallman.blogspot.ca/2017/05/apex-and-ords-up-and-running-in2-steps.html 470 | declare 471 | l_acl_path varchar2(4000); 472 | l_apex_schema varchar2(100); 473 | begin 474 | for c1 in (select schema 475 | from sys.dba_registry 476 | where comp_id = 'APEX') loop 477 | l_apex_schema := c1.schema; 478 | end loop; 479 | sys.dbms_network_acl_admin.append_host_ace( 480 | host => '*', 481 | ace => xs$ace_type(privilege_list => xs$name_list('connect'), 482 | principal_name => l_apex_schema, 483 | principal_type => xs_acl.ptype_db)); 484 | commit; 485 | end; 486 | / 487 | 488 | -- Setup APEX Admin password 489 | begin 490 | apex_util.set_security_group_id( 10 ); 491 | apex_util.create_user( 492 | p_user_name => 'ADMIN', 493 | p_email_address => 'martin@talkapex.com', 494 | p_web_password => 'Oradoc_db1', 495 | p_developer_privs => 'ADMIN', 496 | p_change_password_on_first_use => 'N'); 497 | apex_util.set_security_group_id( null ); 498 | commit; 499 | end; 500 | / 501 | -- Exit SQL 502 | exit 503 | ``` 504 | 505 | ```bash 506 | # You can now exit bash on the container 507 | exit 508 | ``` 509 | 510 | ### ORDS Containers 511 | 512 | Each APEX PDB should have an associated ORDS container. A few notes about each ORDS container: 513 | 514 | - Instead of naming the ORDS containers with their version number, they'll be named to reference the corresponding APEX version (example `ords-504` will be used to reference the PDB hosing APEX `5.0.4`). You may want to alter your naming scheme if you plan to test with multiple versions of ORDS. 515 | - **Important:** Refer to [Docker ORDS](https://github.com/martindsouza/docker-ords) documentation on how to run each ORDS setup. Only modifications will be mentioned in each section below. 516 | 517 | #### ORDS 18.1.0 518 | 519 | ```bash 520 | -- Note: THIS IS NOT A COMPLETE docker run command 521 | -- Please reference https://github.com/martindsouza/docker-ords for full docker run commands 522 | -- The purpose of this is to highlight the passwords and connection strings to use for each PDB 523 | docker run ... 524 | --name ords-1810 \ 525 | --network=oracle_network \ 526 | -e TZ=America/Edmonton \ 527 | -e DB_HOSTNAME=oracle \ 528 | -e DB_PORT=1521 \ 529 | -e DB_SERVICENAME=orclpdb1810.localdomain \ 530 | -e APEX_PUBLIC_USER_PASS=oracle \ 531 | -e APEX_LISTENER_PASS=oracle \ 532 | -e APEX_REST_PASS=oracle \ 533 | -e ORDS_PASS=oracle \ 534 | -e SYS_PASS=Oradoc_db1 \ 535 | ... 536 | ``` 537 | 538 | You should now be able to go to APEX via [http://localhost:31810/ords](http://localhost:32181/ords) 539 | 540 | #### ORDS 5.1.4 541 | 542 | ```bash 543 | -- Note: THIS IS NOT A COMPLETE docker run command 544 | -- Please reference https://github.com/martindsouza/docker-ords for full docker run commands 545 | -- The purpose of this is to highlight the passwords and connection strings to use for each PDB 546 | docker run ... 547 | --name ords-514 \ 548 | --network=oracle_network \ 549 | -e TZ=America/Edmonton \ 550 | -e DB_HOSTNAME=oracle \ 551 | -e DB_PORT=1521 \ 552 | -e DB_SERVICENAME=orclpdb514.localdomain \ 553 | -e APEX_PUBLIC_USER_PASS=oracle \ 554 | -e APEX_LISTENER_PASS=oracle \ 555 | -e APEX_REST_PASS=oracle \ 556 | -e ORDS_PASS=oracle \ 557 | -e SYS_PASS=Oradoc_db1 \ 558 | ... 559 | ``` 560 | 561 | You should now be able to go to APEX via http://localhost:32514/ords 562 | 563 | #### ORDS 5.0.4 564 | 565 | ```bash 566 | -- Note: THIS IS NOT A COMPLETE docker run command 567 | -- Please reference https://github.com/martindsouza/docker-ords for full docker run commands 568 | -- The purpose of this is to highlight the passwords and connection strings to use for each PDB 569 | docker run ... 570 | --name ords-504 \ 571 | ... 572 | --network=oracle_network \ 573 | -e TZ=America/Edmonton \ 574 | -e DB_HOSTNAME=oracle \ 575 | -e DB_PORT=1521 \ 576 | -e DB_SERVICENAME=orclpdb504.localdomain \ 577 | -e APEX_PUBLIC_USER_PASS=oracle \ 578 | -e APEX_LISTENER_PASS=oracle \ 579 | -e APEX_REST_PASS=oracle \ 580 | -e ORDS_PASS=oracle \ 581 | -e SYS_PASS=Oradoc_db1 \ 582 | ... 583 | ``` 584 | 585 | You should now be able to go to APEX via http://localhost:32504/ords 586 | 587 | 588 | #### ORDS Container Wrappup 589 | 590 | When running ORDS containers for the first time they'll run in the foreground as the `-d` (`detached`) option was not provided (see [Docker documentation](https://docs.docker.com/engine/reference/run/#detached--d) for more info on this option). It's good to have it run in the foreground as it's easy to spot any issues with ORDS connecting to the database. 591 | 592 | To stop stop the container hit `ctrl+c`. To restart the ORDS container run `docker start ords-1810`. 593 | 594 | ## Useful Commands 595 | 596 | This section covers some useful commands for Docker and managing Oracle CDB and PDBs. 597 | 598 | ### Quick Start 599 | 600 | To quickly start and stop the docker containers: 601 | 602 | ```bash 603 | # Start 604 | docker start oracle 605 | docker start ords-504 606 | docker start ords-514 607 | docker start ords-1810 608 | 609 | # Stop 610 | docker stop -t 200 oracle 611 | docker stop -t 200 ords-504 612 | docker stop -t 200 ords-514 613 | docker stop -t 200 ords-1810 614 | 615 | ``` 616 | 617 | ### Docker 618 | 619 | ```bash 620 | # Docker stop conainer with timeout (for Oracle to shutdown properly) 621 | docker stop -t 200 oracle 622 | 623 | # Docker stop all containers 624 | docker stop -t 200 $(docker ps) 625 | 626 | # Delete all containers 627 | docker rm $(docker ps -aq) 628 | 629 | # Delete all images 630 | docker rmi $(docker images -aq) 631 | 632 | # View docker logs as run is happening where is the name of the container that is running 633 | docker logs 634 | 635 | 636 | # Docker Network 637 | # List 638 | docker network ls 639 | 640 | # See containers on network 641 | docker network inspect oracle_network 642 | ``` 643 | 644 | 645 | ### Oracle 646 | 647 | #### Connection Strings 648 | 649 | ```bash 650 | sqlcl sys/Oradoc_db1@localhost:32122:orclcdb as sysdba 651 | sqlcl sys/Oradoc_db1@localhost:32122/orclpdb1.localdomain as sysdba 652 | sqlcl sys/Oradoc_db1@localhost:32122/orclpdb504.localdomain as sysdba 653 | sqlcl sys/Oradoc_db1@localhost:32122/orclpdb514.localdomain as sysdba 654 | sqlcl sys/Oradoc_db1@localhost:32122/orclpdb1810.localdomain as sysdba 655 | ``` 656 | 657 | #### DBA 658 | 659 | ```sql 660 | 661 | # Drop PDB 662 | drop pluggable database orclpdb1810 including datafiles; 663 | drop pluggable database orclpdb514 including datafiles; 664 | drop pluggable database orclpdb504 including datafiles; 665 | 666 | # Create tablespace (as PDB DBA) 667 | create tablespace users 668 | datafile 'users-1810.dat' 669 | size 100m 670 | autoextend on 671 | next 20m 672 | online 673 | ; 674 | 675 | # Create user (as sys) 676 | -- Create account to develop with 677 | define new_user = 'martin' 678 | create user &new_user. identified by &new_user. container = current; 679 | grant connect, resource, create job, create view, create any context to &new_user; 680 | alter user &new_user quota unlimited on users; 681 | alter user &new_user default tablespace users; 682 | ``` 683 | 684 | #### Sample Data 685 | 686 | Using SQLcl you can create the `dept` and `emp` table your schema using the following script: 687 | 688 | ```sql 689 | @https://raw.githubusercontent.com/OraOpenSource/OXAR/master/oracle/emp_dept.sql 690 | ``` 691 | 692 | ## Common Problems 693 | 694 | ### Oracle Docker Container 695 | 696 | #### Issues writing to `/ORCL` folder 697 | 698 | If you get issues from the `docker logs oracle` command such as: 699 | 700 | ```bash 701 | ls: cannot open directory /ORCL: Permission denied 702 | # or 703 | mkdir: cannot create directory '/ORCL/u01': Permission denied 704 | ``` 705 | 706 | It could be due to SE Linux. The following worked for me to get around this: 707 | 708 | - [Disable SE Linux](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/security-enhanced_linux/sect-security-enhanced_linux-enabling_and_disabling_selinux-disabling_selinux) 709 | - Set `SELINUX=disabled` in `/etc/selinux/config` 710 | - Reboot host OS (i.e. laptop) 711 | - Running `getenforce` should return `Disabled` or `Permissive` 712 | - Change permission on `~/docker/oracle` and `~/docker/apex` folders 713 | ```bash 714 | chmod 777 ~/docker/oracle 715 | chmod 777 ~/docker/apex 716 | ``` 717 | - _Optional_ Disable SE Linux on specific folders 718 | ```bash 719 | chcon -Rt svirt_sandbox_file_t ~/docker/oracle 720 | chcon -Rt svirt_sandbox_file_t ~/docker/apex 721 | ``` 722 | --------------------------------------------------------------------------------