├── .dockerignore ├── .github └── FUNDING.yml ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── assets └── fake-swap.sh ├── build-wrapper.sh └── config ├── init.ora ├── initXETemp.ora ├── start.sh └── xe.rsp /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .gitignore 3 | build-wrapper.sh 4 | 5 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: 2 | - madhead 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | rpm 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:centos7 2 | 3 | MAINTAINER Siarhei Krukau 4 | 5 | # Pre-requirements 6 | RUN mkdir -p /run/lock/subsys 7 | 8 | RUN yum install -y libaio bc initscripts net-tools; \ 9 | yum clean all 10 | 11 | # Create fake 'free' command to spoof swap space 12 | RUN mv /usr/bin/free /usr/bin/free.orig 13 | ADD assets/fake-swap.sh /tmp/fake-free.sh 14 | CMD /tmp/fake-swap.sh \ 15 | && rm /tmp/fake-swap.sh 16 | 17 | # Install Oracle XE 18 | ADD rpm/oracle-xe-11.2.0-1.0.x86_64.rpm.tar.gz /tmp/ 19 | RUN yum localinstall -y /tmp/oracle-xe-11.2.0-1.0.x86_64.rpm; \ 20 | rm -rf /tmp/oracle-xe-11.2.0-1.0.x86_64.rpm 21 | 22 | # Restore 'free' command 23 | RUN mv /usr/bin/free.orig /usr/bin/free 24 | 25 | # Configure instance 26 | ADD config/xe.rsp config/init.ora config/initXETemp.ora /u01/app/oracle/product/11.2.0/xe/config/scripts/ 27 | RUN chown oracle:dba /u01/app/oracle/product/11.2.0/xe/config/scripts/*.ora \ 28 | /u01/app/oracle/product/11.2.0/xe/config/scripts/xe.rsp 29 | RUN chmod 755 /u01/app/oracle/product/11.2.0/xe/config/scripts/*.ora \ 30 | /u01/app/oracle/product/11.2.0/xe/config/scripts/xe.rsp 31 | ENV ORACLE_HOME /u01/app/oracle/product/11.2.0/xe 32 | ENV ORACLE_SID XE 33 | ENV PATH $ORACLE_HOME/bin:$PATH 34 | 35 | RUN /etc/init.d/oracle-xe configure responseFile=/u01/app/oracle/product/11.2.0/xe/config/scripts/xe.rsp 36 | 37 | # Run script 38 | ADD config/start.sh / 39 | CMD /start.sh 40 | 41 | EXPOSE 1521 42 | EXPOSE 8080 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | http://www.oracle.com/technetwork/licenses/database-11g-express-license-459621.html 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | *** 2 | 3 |

4 | ⚠️ Please, use one of the official images instead ⚠️ 5 |

6 | 7 | *** 8 | 9 | # Containerized Oracle XE 11g 10 | 11 | This repo contains a [Dockerfile](https://www.docker.com/) to create an image with [Oracle Database 11g Express Edition](http://www.oracle.com/technetwork/database/database-technologies/express-edition/overview/index.html) running in [CentOS 7](http://www.centos.org/) 12 | 13 | ## Why one more Docker image for Oracle XE? 14 | 15 | The main reason for this repo is to have clean and transparent Dockerfile, without any magic behind. 16 | It is based on [official CentOS images](https://registry.hub.docker.com/_/centos/) and the build is completely described in the Dockerfile. 17 | Unlike many other images on the Net this one uses stock rpm installer provided by Oracle, not repacked by `alien`. 18 | 19 | ## How to build 20 | 21 | Let's assume that you are familar with Docker and building Docker images from [Dockerfiles](http://docs.docker.com/reference/builder/). 22 | 23 | 1. Download the [rpm installer](http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html). 24 | 1. Unzip it and pack `oracle-xe-11.2.0-1.0.x86_64.rpm` in `tar.gz` archive named `oracle-xe-11.2.0-1.0.x86_64.rpm.tar.gz` so that it's contents look like: 25 | 26 | % tar -tf oracle-xe-11.2.0-1.0.x86_64.rpm.tar.gz 27 | oracle-xe-11.2.0-1.0.x86_64.rpm 28 | 29 | 1. Place the tarball inside the `rpm` directory of this repo. 30 | 1. Run `docker build -t "madhead/docker-oracle-xe" .` from the root directory of this repo. 31 | 1. You should get your image ready in a few minutes (apart from downloading base `centos:centos7` image). 32 | 33 | During the configuration of Oracle XE instance two files - `init.ora` and `initXETemp.ora` - are overridden with ones from `config` directory of this repo. 34 | The only difference is that `memory_target` parameter is commented in them to prevent `ORA-00845: MEMORY_TARGET not supported on this system` error. 35 | The only piece of magic in this image :). 36 | 37 | ## How to use 38 | 39 | Basically `docker run -p 8089:8080 -p 1521:1521 -d madhead/docker-oracle-xe` will start new container and bind it's local ports `1521` and `8080` to host's `1521` and `8089` respectively. 40 | Read [Docker documentation](http://docs.docker.com/userguide/usingdocker/) for details. 41 | 42 | Oracle Web Management Console (apex) will be available at [http://localhost:8089/apex](http://localhost:8089/apex). 43 | Use the following credentials to login: 44 | 45 | workspace: INTERNAL 46 | user: ADMIN 47 | password: oracle 48 | 49 | Connect to the database using the following details: 50 | 51 | hostname: localhost 52 | port: 1521 53 | sid: XE 54 | username: system 55 | password: oracle 56 | -------------------------------------------------------------------------------- /assets/fake-swap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cat >/usr/bin/free <<'EOF' 3 | #!/bin/sh 4 | cat <<'__eof' 5 | total used free shared buffers cached 6 | Mem: 1048576 327264 721312 0 0 0 7 | -/+ buffers/cache: 327264 721312 8 | Swap: 2000000 0 2000000 9 | __eof 10 | exit 11 | EOF 12 | chmod 755 /usr/bin/free 13 | exit 14 | -------------------------------------------------------------------------------- /build-wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Copyright (c) 2015 Uli Fuchs 5 | # Released under the terms of the MIT License 6 | # 7 | 8 | # Gets the value of a given key in '/proc/meminfo' 9 | # @param1 string - key name, e.g. 'MemTotal' 10 | # @return integer - value in MB 11 | function getMemInfo() { 12 | 13 | local mem=$(cat /proc/meminfo | grep "$1" | awk '{print $2}') 14 | 15 | echo $(expr $mem / 1024) 16 | } 17 | 18 | # Checks if the system provides 2048MB _free_ swap space. 19 | # This will be tested by Oracle before the rpm installer runs. 20 | # @return integer - 1 if less than 2048 swap space available otherwise 0 21 | function needExtraSwapSpace() { 22 | 23 | local swapFree=$(getMemInfo "SwapFree") 24 | 25 | [ $swapFree -lt 2048 ] && echo 1 || echo 0 26 | } 27 | 28 | NEED_EXTRASWAP=$(needExtraSwapSpace) 29 | SWAPFILE=/root/swapfile 30 | 31 | [ $NEED_EXTRASWAP -eq 1 ] && { 32 | echo 33 | echo =================================================================================== 34 | echo "There are only $(getMemInfo "SwapFree")MB free swap space available but it needs 2048MB." 35 | echo "Creating extra swap space of 2048MB. This takes some seconds..." 36 | sudo dd if=/dev/zero of=$SWAPFILE count=1024 bs=2097152 &> /dev/null 37 | sudo mkswap -c $SWAPFILE 38 | sudo swapon $SWAPFILE 39 | echo 40 | swapon -s 41 | echo =================================================================================== 42 | echo 43 | } 44 | 45 | docker build -t "madhead/docker-oracle-xe" . 46 | 47 | [ $NEED_EXTRASWAP -eq 1 ] && { 48 | echo 49 | echo =================================================================================== 50 | echo "Removing the extra swap space" 51 | sudo swapoff $SWAPFILE 52 | sudo rm -f $SWAPFILE 53 | echo 54 | swapon -s 55 | echo =================================================================================== 56 | echo 57 | } 58 | 59 | -------------------------------------------------------------------------------- /config/init.ora: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Copyright (c) 1991, 2011, Oracle and/or its affiliates. All rights reserved. 3 | ############################################################################## 4 | 5 | ########################################### 6 | # Cursors and Library Cache 7 | ########################################### 8 | open_cursors=300 9 | 10 | ########################################### 11 | # Database Identification 12 | ########################################### 13 | db_name=XE 14 | 15 | ########################################### 16 | # File Configuration 17 | ########################################### 18 | control_files=("/u01/app/oracle/oradata/XE/control.dbf") 19 | DB_RECOVERY_FILE_DEST=/u01/app/oracle/fast_recovery_area 20 | DB_RECOVERY_FILE_DEST_SIZE=10G 21 | 22 | ########################################### 23 | # Job Queues 24 | ########################################### 25 | job_queue_processes=4 26 | 27 | ########################################### 28 | # Miscellaneous 29 | ########################################### 30 | compatible=11.2.0.0.0 31 | diagnostic_dest=/u01/app/oracle 32 | # memory_target=%memory_target% 33 | 34 | ########################################### 35 | # Sessions 36 | ########################################### 37 | sessions=20 38 | 39 | ########################################### 40 | # Security and Auditing 41 | ########################################### 42 | audit_file_dest=/u01/app/oracle/admin/XE/adump 43 | remote_login_passwordfile=EXCLUSIVE 44 | 45 | ########################################### 46 | # Shared Server 47 | ########################################### 48 | dispatchers="(PROTOCOL=TCP) (SERVICE=XEXDB)" 49 | shared_servers=4 50 | 51 | ########################################### 52 | # System Managed Undo and Rollback Segments 53 | ########################################### 54 | undo_management=AUTO 55 | undo_tablespace=UNDOTBS1 56 | -------------------------------------------------------------------------------- /config/initXETemp.ora: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Copyright (c) 1991, 2011, Oracle and/or its affiliates. All rights reserved. 3 | ############################################################################## 4 | 5 | ########################################### 6 | # Cursors and Library Cache 7 | ########################################### 8 | open_cursors=300 9 | 10 | ########################################### 11 | # Database Identification 12 | ########################################### 13 | db_name=XE 14 | 15 | ########################################### 16 | # File Configuration 17 | ########################################### 18 | control_files=("/u01/app/oracle/oradata/XE/control.dbf") 19 | DB_RECOVERY_FILE_DEST_SIZE=10G 20 | DB_RECOVERY_FILE_DEST=/u01/app/oracle/fast_recovery_area 21 | 22 | ########################################### 23 | # Job Queues 24 | ########################################### 25 | 26 | ########################################### 27 | # Miscellaneous 28 | ########################################### 29 | compatible=11.2.0.0.0 30 | diagnostic_dest=/u01/app/oracle 31 | # memory_target=%memory_target% 32 | 33 | ########################################### 34 | # Sessions 35 | ########################################### 36 | sessions=20 37 | 38 | ########################################### 39 | # Security and Auditing 40 | ########################################### 41 | audit_file_dest=/u01/app/oracle/admin/XE/adump 42 | remote_login_passwordfile=EXCLUSIVE 43 | 44 | ########################################### 45 | # Shared Server 46 | ########################################### 47 | dispatchers="(PROTOCOL=TCP) (SERVICE=XEXDB)" 48 | 49 | ########################################### 50 | # System Managed Undo and Rollback Segments 51 | ########################################### 52 | undo_management=AUTO 53 | undo_tablespace=UNDOTBS1 54 | _no_recovery_through_resetlogs=true 55 | -------------------------------------------------------------------------------- /config/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Update HOST with actual value, uniquely generated by Docker on each start 4 | sed -i -E "s/HOST = [^)]+/HOST = $HOSTNAME/g" $ORACLE_HOME/network/admin/listener.ora 5 | sed -i -E "s/HOST = [^)]+/HOST = $HOSTNAME/g" $ORACLE_HOME/network/admin/tnsnames.ora 6 | 7 | while true; do 8 | pmon=`ps -ef | grep pmon_$ORACLE_SID | grep -v grep` 9 | 10 | if [ "$pmon" == "" ] 11 | then 12 | date 13 | /etc/init.d/oracle-xe start 14 | fi 15 | sleep 1m 16 | done; 17 | -------------------------------------------------------------------------------- /config/xe.rsp: -------------------------------------------------------------------------------- 1 | ORACLE_HTTP_PORT=8080 2 | ORACLE_LISTENER_PORT=1521 3 | ORACLE_PASSWORD=oracle 4 | ORACLE_CONFIRM_PASSWORD=oracle 5 | ORACLE_DBENABLE=y 6 | --------------------------------------------------------------------------------