Can Docker help me install Oracle 11g database on Ubuntu?

We are struggling with a common problem of trying to provide an Oracle 11g instance for our developers to test with. Our standard build agents are based on Ubuntu 12.04 but Oracle supports only RedHat based OS's.

There are some hacks about installing Oracle on Ubuntu floating around the net but they seem to be very fragile and a matter of hit-and-miss.

We want to avoid having to support an entire build server Puppet configuration on top of RedHat(/CentOS) just in order to support Oracle so I was beginning to wonder whether we can employ Docker to provide a RedHat-like environment required just for Oracle on top of our standard Ubuntu systems. The idea is that Oracle will run in its own container but the rest of the build agent will still run on standard Ubuntu, able to talk to Oracle over TCP.

I know what LXC's are and the difference between them and full-fledged virtualization like KVM/VirtualBox etc, but I was wondering whether it could still be possible.

Thanks.

If Oracle Express is suitable for you:

  1. Download Oracle XE 11g rpm.
  2. Convert rpm to deb using alien.
  3. "Extract" the deb package using dpkg-deb command.
  4. Modify the deb scripts:
    • Change [ "$1" != "1" ] to [ "$1" != "install" ] at the beginning of preinst.
    • Change [ "$1" = "1" -o -z "$2" ] to [ "$1" = "configure" -a -z "$2" ] at the beginning of postint.
    • Change [ "$1" = "0" ] to [ "$1" = "remove" -o "$1" = "purge" ] in prerm & postrm.
    • Change 'chkconfig' to 'update-rc.d' command in postinst & prerm.
    • In init script: remove absolute path of some system commands; fix /etc/sysconfig/oracle-xe to /etc/default/oracle-xe; fix /var/lock/subsys to /var/lock; and so on...
    • Add dependencies to control file: bc & libaio1.
  5. Build the deb package using deb command.

Now you have a deb package of Oracle XE 11g. Install it!

But there's still a problem: /dev/shm. Here how to fix it:

  1. Comment the line in /etc/init/mounted-dev.conf: [ -e /dev/shm ] || ln -s /run/shm /dev/shm.
  2. Add a line in /etc/fstab: shm /dev/shm tmpfs size=2g 0 0
  3. rm -f /dev/shm; mkdir /dev/shm; mount shm

Start Oracle XE: service oracle-xe configure

Here is my fork:

  • Reduce size of image from 3.8G to 825MB
  • Database initialization moved out of the image build phase
  • Now database initializes at the containeer startup with no database files mounted
  • Media reuse support outside of container
  • Added graceful shutdown on container stop
  • Removed sshd

You may check here:
https://registry.hub.docker.com/u/sath89/oracle-xe-11g/
https://github.com/MaksymBilenko/docker-oracle-xe-11g

I am using the following docker image with a good level of success.

Get it to run with:

 docker pull wnameless/oracle-xe-11g

and

 docker run -d -p 49160:22 -p 49161:1521 wnameless/oracle-xe-11g

I can confirm that Oracle XE works within Docker. the only issue is that inside the container the shm is configured to only 65356k see https://github.com/dotcloud/docker/issues/2606 The only workaround so far is to change the lxc template and recompile docker (which is easy)

This is definitely a feasible approach. We use Ubuntu 14.04 for our host machines and run several Oracle 11g instances within Docker containers for development purposes as well.

Currently (Docker 1.5) for both 11g and 12c the main issue is Docker's hard-coded shared memory limit Issue #2606. There are currently two workarounds for this:

  1. Use docker run --privileged ... and remount /dev/shm with more memory before starting the instance
  2. Modify and rebuild Docker yourself. For this case I've put together a Dockerfile for 12c which allows creating an image in one go: https://github.com/arpagaus/docker-oracle-12c

You can use OEL 6.5 LXC Linux Containers ontop of Ubuntu 14.04 as described step-by-step here at my blog:

https://sites.google.com/site/nandydandyoracle/technologies/lxc/oracle-lxc-vlc

If you expect to get any type of support from Oracle on this, forget this idea…

Oracle RDMS is a monster… It’s NOT meant to be a simple, install this here and use at will database. It is intense and oracle wants you know that. If your developers are truly tied to ubuntu, I would try to reevaluate your need for Oracle 11g (If you dont need an enterprise distro you probably dont need an enterprise RDMS). It sounds an awful lot like you are employing KISS with the build agent and forgetting about absolutely everything else.

I looked into docker just this morning, it didn’t strike me as production ready, at all. tbh.

@Sirex I’d be interested to hear what issues you had with it. I’ve been beta testing docker with several parts of our SaaS product, and haven’t run into a single issue yet.

@EEAA, browsing around their github issues when people were asking for the (elephant in the room) RHEL support and seeing how there were comments considering a needed move away from aufs due to ubuntu ditching it. The consensus was to move to btrfs which isn’t out of tech preview until RHEL7. There were also some pretty caviler attitudes to putting 3.10+ custom kernels onto RHEL boxes to make docker go. Overall i really liked the concept, but i think it’ll be some time before i’d be happy to roll it out. Only a quick cursory glance though, so YMMV.

To clarify - I’m in the build engineering business of a pure software company. This isn’t for internal consumption but for verifying that our web applications can talk to Oracle. We use Oracle Express for that and don’t need Oracle’s support.