Justin's Blog

Implement Oracle Database XE as Docker Containers

Justin Paul
Senior Principal Consultant
This post shows you how to create Docker Images with Oracle Database Express Edition installed and configured. Download the entire project directory from GitHub here.

If you have tried to create Docker containers for Oracle Database XE, you will not be able to configure/start a database instance successfully. The installation may complete successfully but when you try to configure or start an instance, you will notice the following error in the logs. 

ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
ORA-00845: MEMORY_TARGET not supported on this system

On further investigation, you will notice that the shared memory [/dev/shm] available to a Docker container is 64MB in the current public Docker version and Oracle Database XE requires at least 1GB of shared memory. If you edit the [/u01/app/oracle/product/11.2.0/xe/config/scripts/init.ora] file to either comment or change the memory_target parameter, you may be able to complete the configuration and start the database. However, you will still see this error and you may not be able to use the database at all.

There is no way to can change the shared memory available when building a Docker image or when creating containers. Development of an option to specify the shared memory available using "--shm-size=x[b|m|g]" is in progress and you can find more information regarding this thread here: https://github.com/docker/docker/issues/16164.

This feature should be part of the Docker 1.10 release; however, this fix is available in the current experimental build. If you are open to using the beta version of the software, here is how I implemented the Oracle Database XE in Docker.

I have used a Ubuntu 15.10 virtual machine for this exercise. You can install the latest Docker experimental build from https://experimental.docker.com. Update the kernel parameters on the host machine to meet the Oracle requirements. These requirements can be found on the webpage here: http://docs.oracle.com/cd/E17781_01/install.112/e18802/toc.htm#BABJFAIA.

kernel.sem="250 32000 100 128"
net.ipv4.ip_local_port_range="9000 65000"

Once the environment is setup and ready to go, the next step is to identify a Docker build context directory and create the necessary folder structure. 

mkdir ~/database
cd ~/database
mkdir xe

After the directories are setup, all the necessary installers should be downloaded. If you have downloaded the project files from GitHub, you can find the instructions to download the files under the respective directory. You can also click on a directory below to see the instructions. At the end you should have a directory structure shown below. 


 - xe

  - Dockerfile.

  - oracle-xe-11.2.0-1.0.x86_64.rpm.zip

Create or edit the Dockerfile in your context directory. For this post, the Dockerfile is named as Dockerfile. 

FROM oraclelinux:6


ENV _SCRATCH /tmp/scratch

COPY db/oracle-xe-11.2.0-1.0.x86_64.rpm.zip ${_SCRATCH}/db/

RUN yum update -y -q && \

  yum install -y -q binutils compat-libcap1 compat-libstdc++-33 \

  compat-libstdc++-33.i686 gcc gcc-c++ glibc glibc-devel glibc-devel.i686 \

  libaio libaio-devel libgcc libgcc.i686 libstdc++ libstdc++.i686 \

  libstdc++-devel libXext libXtst libXi openmotif openmotif22 redhat-lsb \

  sysstat zlib zlib.i686 libX11 libX11.i686 unzip xorg-x11-utils xorg-x11-xauth

RUN unzip ${_SCRATCH}/db/oracle-xe-11.2.0-1.0.x86_64.rpm.zip -d ${_SCRATCH}/db && \

  rpm -ivh ${_SCRATCH}/db/Disk1/oracle-xe-11.2.0-1.0.x86_64.rpm && \

  sed -i 's/ORACLE_PASSWORD=/ORACLE_PASSWORD=welcome1/g' \

  ${_SCRATCH}/db/Disk1/response/xe.rsp && \


  ${_SCRATCH}/db/Disk1/response/xe.rsp && \

  /etc/init.d/oracle-xe configure responseFile=${_SCRATCH}/db/Disk1/response/xe.rsp

RUN rm -rf ${_SCRATCH}

CMD /etc/init.d/oracle-xe start && /bin/bash

Run the following command to build your image. Use --no-cache=true if you do not want to cache intermediate images. 

cd ~/database
docker build -t oracle/db/xe: --shm-size=2g -f ./xe/Dockerfile. .

After the image(s) are built, we can create the container. Run the following command to create and start your database container. Use the -d flag instead of -i to force the container to run as a background process. 

docker run -i -P --name=oracle-db-xe-1 --shm-size=2g -t oracle/db/xe:

NOTE: Please note that these instructions should be used for development and evaluation purposes only, as such they are unsupported and should not be used on production environments.

Join the discussion

Comments ( 7 )
  • guest Thursday, March 3, 2016

    Hello Justin,

    As far I understand Oracle Database Express is suitable for Independent Software Vendors and hardware vendors who want a starter database to distribute free of charge.

    Is it conform with the Oracle Technology Network Developer License Terms for Oracle Database Express Edition to distribute the Oracle Database Express Edition with my program on Docker Hub?



  • Justin Paul Thursday, March 3, 2016

    Hello Nat,

    Please read the product documentation page for details: http://www.oracle.com/technetwork/database/database-technologies/express-edition/overview/index.html.

    If you still have questions, contact Oracle Sales. Contact is usually provided at the bottom right corner of the Oracle webpages.



  • guest Sunday, March 13, 2016

    Hi Justin,

    I get an rpm error that there isn't enough swap space, do you know how we configure this? Thanks.

    This system does not meet the minimum requirements for swap space. Based on

    the amount of physical memory available on the system, Oracle Database 11g

    Express Edition requires 2048 MB of swap space. This system has 472 MB

    of swap space. Configure more swap space on the system and retry the


  • Justin Paul Sunday, March 13, 2016

    Usually you configure the swap space at OS installation and it is set to a value equal to the available memory for most Oracle products. You will have to resize your SWAP partition using a disk management utility.

    Maybe this discussion on Docker Community Forum will help you: https://forums.docker.com/t/docker-swap-space/3908.

  • pcouas Friday, September 23, 2016

    Hi, discussion on docker forum don't exist.

    On windows7 i have increase swap memory in advanced parameter, without succes ?


  • Metin Yaylacioglu Monday, October 31, 2016

    The problems on windows 7 are related to boot2docker and the fact that it only provides limited space on /dev/shm on the boot2docker vm image itself.

  • John Coakley Saturday, January 27, 2018
    Hi Justin
    Interesting article - I am wondering how Oracle database handles the multiple processes needed (e.g. lgwr, dbwr, pmon, smon and loads more), particularly as the single container will run in a single host process...do you use Supervisord or other techniques to deal with this? I am struggling to understand what happens in practice. I appreciate your help. Thanks Jcc
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.