Running Oracle XE in a Docker Container on MacOS

This post shows how to build and start Oracle XE on MacOS using the Docker image provided by https://github.com/wnameless/docker-oracle-xe-11g.

Step 1: Start Docker

Start formerly installed default Docker instance using docker-machine:

> docker-machine ls
NAME      ACTIVE   DRIVER       STATE   URL   SWARM   DOCKER    ERRORS
default   -        virtualbox   Saved                 Unknown   
> docker-machine start default

Check if the Docker instance is running:

> docker-machine ls    
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS
default   *        virtualbox   Running   tcp://192.168.99.100:2376           v1.10.2   

Set enviromnental parameters to be able to commumicate with the Docker instance:

eval $(docker-machine env)

Step 2: Pull or build Docker image

Build the Docker image on your own:

> git clone https://github.com/wnameless/docker-oracle-xe-11g
> cd docker-oracle-xe-11g
> docker build  -t wnameless/oracle-xe-11g .

Check the image:

docker images     
REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
wnameless/oracle-xe-11g    latest              45bd9967896a        About an hour ago   2.389 GB

Or just pull the image from the repository (lazy way):

> docker pull wnameless/oracle-xe-11g

Step 3: Run

Run the container with 22 and 1521 ports opened:

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

Step 4: Test

Connect to database with DB client, e.g. SQLDeveloper, using default settings:

hostname: ~~localhost~~ <IP>
port: 49161
sid: xe
username: system
password: oracle

Using docker-machine on MacOS, localhost does not work. Use the <IP> adress given by following command instead:

> docker-machine ip

Connect with SSH to the container (password: admin), using the same <IP> adress as above:

> ssh root@~~localhost~~<IP> -p 49160    

Tags docker macos database