Installing Apex on a Linux Virtual Box Machine Using Docker

Problem

How to get Oracle with Apex quickly installed on a Ubuntu Linux box.
I've previously installed Oracle (EBS, database and Apex with middleware) on a Ubuntu Linux on a virtual machine, and it was very frustrating. I needed a quicker way to get a database and Apex up and running, and I wanted it to be on the free version of the database. I stumbled upon a thread, and then through trial and error I managed to get it up an running. Acknowledgements at the end of the post.

Solution


This one is the nicest way to install Oracle XE. 
Docker is an application container for Linux. It is based onLXC and gives you the ability to package complete application including their dependencies to a self-containing file (called an image). These images can be exchanged and run on every Linux machine where Docker is installed! Awesome!
Docker images are also shared around the community on https://index.docker.io. And this is where this two guys come into play:
• Wei-Ming Wu made a Docker image containing Oracle XE. 
• Alexei Ledenev extended Wei-Ming Wu’s image to also use the Oracle web console (APEX). 

Install Docker from the Ubuntu Terminal

I've put sudo in front of all my commands because I had trouble getting the security group right - and frankly, if sudo worked - I was happy to use it.

which wget

(If wget is not installed, install it)
sudo apt-get update $ sudo apt-get install wget


1. Get the latest Docker package.
$ wget -qO- https://get.docker.com/ | sh
The system prompts you for your sudo password. Then, it downloads and installs Docker and its dependencies.
2. Verify docker is installed correctly.
$ sudo docker run hello-world

3. This bit didn't work for me, but it might for you - it is supposed to stop you from having to type "sudo" in front of every docker command.
sudo usermod -aG docker barry
sudo gpasswd -a ${USER} docker
(then restart the terminal)
sudo service docker restart

Download the Oracle Image from the central respository

sudo docker pull alexeiled/docker-oracle-xe-11g

Running the Docker Image


sudo docker run -d -p 49160:22 -p 49161:1521 -p 49162:8080 alexeiled/docker-oracle-xe-11g
It takes a split second so you don't think that anything has happenened. But believe it or not, Oracle is now running.

Connect database with following setting:  
hostname: localhost 
port: 49161 
sid: xe 
username: system 
password: oracle 
Password for SYS  oracle 

Connect to Oracle Application Express web management console with following settings:
  url: http://localhost:49162/apex 
workspace: INTERNAL 
user: ADMIN 
password: oracle
Login by SSH  (from the terminal)
ssh root@localhost -p 49160 
password: admin


Some useful Docker Commands


sudo docker ps -a
List all containers on the machine
Sudo docker ps
List of all containers running.
Sudo docker images
Current images
Sudo docker logs <container#>
Shows output from running containers
Sudo docker inspect <container#>
Shows helpful information about the running container
Sudo docker stop <container#>
Stops the container from running, but it is still on the machine.
("docker ps" will not show it, but "docker ps -a" shows that it is on the machine
Sudo docker start <container#>
Starts the above machine
Sudo docker commit -m "new images" e2029404545 bbrierley/newhome
Creates a new image where e2029404545  is the original image to copy from, and bbrierley/newhome is the name of the new image.

Do a "docker images" to see it succesfully created
Docker login
Docker push bbrierley/newhome
Use this to upload your image to the docker repository
Docker pull bbrierley/newhome
Get the image from the repository


Copying files to a Docker Container

1. Get container name or short container id :
$ docker ps
2. Get full container id
$ docker inspect -f   '{{.Id}}'  SHORT_CONTAINER_ID-or-CONTAINER_NAME
3. copy file :
$ sudo cp path-file-host /var/lib/docker/aufs/mnt/FULL_CONTAINER_ID/PATH-NEW-FILE 
EXAMPLE :
$ docker ps
CONTAINER ID      IMAGE    COMMAND       CREATED      STATUS       PORTS        NAMES
d8e703d7e303   solidleon/ssh:latest      /usr/sbin/sshd -D                      cranky_pare
$ docker inspect -f   '{{.Id}}' cranky_pare
or
$ docker inspect -f   '{{.Id}}' d8e703d7e303
d8e703d7e3039a6df6d01bd7fb58d1882e592a85059eb16c4b83cf91847f88e5

MY EXAMPLE
$ sudo cp file.txt /var/lib/docker/aufs/mnt/**d8e703d7e3039a6df6d01bd7fb58d1882e592a85059eb16c4b83cf91847f88e5**/root/file.txt

Copying Files from a Docker Container


docker cp <containerId>:/file/path/within/container /host/path/target

Mounting a directory while launching Docker


sudo docker run -d -p 49160:22 -p 49161:1521 -p 49162:8080 -v /home/barry/Downloads:/root/Downloads bbrierley/letchworth_apex

Acknowledgements

http://tuhrig.de/3-ways-of-installing-oracle-xe-11g-on-ubuntu/
http://techblog.roethof.net/category/virtualization/docker/> 
https://docs.docker.com/installation/ubuntulinux/
https://registry.hub.docker.com/u/alexeiled/docker-oracle-xe-11g/
https://www.youtube.com/watch?v=VeiUjkiqo9E




Comments