DEV Community

Ayan Dhara
Ayan Dhara

Posted on

Installing Oracle DB 11g on linux using Docker

Oracle DB is one of the most popular Database Software

Here I am going to show how to install Oracle DB 11g an older but easy to use version on linux in a docker container.

1. Setup Docker

So first let's install docker:-

debian based systems
sudo apt install docker.io

arch based systems:-
sudo pacman -S docker

Now it's time to start with it

You need add current user to docker group
sudo usermod -aG docker $USER

then reboot or relogin your mechine or run
newgrp docker

2. Add swap space

now you need to have enough swap space for installing oracle DB.
Minimum 2GiB is required.
But it will be better to add swap space equel to total ram of the mechine.
(If you already have swap space added you can skip to Oracle Linux Installation)

create a swap file
sudo fallocate -l 4G /swapfile

set permissions
sudo chmod 600 /swapfile

set swap area and activate
sudo mkswap /swapfile
sudo swapon /swapfile

swap space will be deactivate on reboot.
to actvate automatically on reboot add

/swapfile swap swap defaults 0 0

this line to /etc/fstab
using editor or by
sudo nano /etc/fstab

now to verify swap added successfully run
sudo swapon --show

3. Install or add oracle db to docker

To pull oracle db image from docker repo and run it
docker run -d oracleinanutshell/oracle-xe-11g

But you need to expose necessary ports.
Default port for Express WebApp is 8080 and Database will run on 1521 (you can change it while installing)

so now stop and delete the docker container using
docker stop <container-id> then
docker rm <container-id>
(container id will be printed on terminal while running docker)

so final command with open port will be
docker run -d -p 1521:1521 -p 8080:8080 oracleinanutshell/oracle-xe-11g

now if you want to restart the server (docker container on restart) then instead of above command you need to run
docker run -d --restart unless-stopped -p 1521:1521 -p 8080:8080 oracleinanutshell/oracle-xe-11g

and to manually start the container run
docker start <container-id>

Top comments (0)