Creating an Oracle Linux ASM Docker Image over Ubuntu 14.04


  • 64-bit Ubuntu 14.04 server

General Information

In this setup we are:

  • Installing Docker
  • Creating a non-root user with Sudo and Docker privileges (axxana)
  • ASM device is /dev/sdb1.
  • Enabling SQLNET and SSH to the container
  • The default ASM port is 1521.
  • The SSH port is 2222.
  • The password for root and grid OS users in the container is axxana.
  • The password for sys ASM user is axxana.
  • The grid software is 12.2 without any patches.
  • The container operating system is Oracle Linux 7.5.
  • Within the container, there is no use of UDEV / ASMLIB or ASMFD: asm_diskstring=’/dev/asm*’,’/bbx/data/*’,’/dev/*’
  • All tests are done on regular Ubuntu 14.04 and on Axxana’s ISO (based on 14.04).
  • There is a crontab job to keep 15 days of trace files and remove audit files.

Apply UDEV rules to make sure the device has permissions of the same container IDs:

vi /etc/udev/rules.d/100-asm.rules

KERNEL==”sdb1“, NAME=”ASM_DISK”, OWNER=”54421″, GROUP=”54421″, MODE=”0660″


udevadm trigger –sysname-match=sdb1 –verbose

Verify the device has ASM labels:

DISK_GROUP=$( blkid | grep oracleasm | sed ‘s/.*LABEL=\”\([^\”]*\)\” TYPE=\”oracleasm\”/\1/’)

if [ -z “$DISK_GROUP” ]


echo “device /dev/sdb1 has not asm metadata”


echo “device /dev/sdb1 has diskgroup $DISK_GROUP”


Install Docker

On Black Box as root:

curl -fsSL | sh


curl -fsSL | sudo apt-key add –

add-apt-repository “deb [arch=amd64] $(lsb_release -cs) stable”

apt-get update

apt-cache policy docker-ce

apt-get install -y docker-ce


service docker status

Add Users

On Black Box as root:

Add equivalent user IDs to the docker to follow (will be identified from outside):

groupadd -g 54422 asmadmin

useradd -u 54421 -g 54422 grid

Add a dedicated user to manage the docker:

adduser axxana -g 54422

echo “axxana:axxana” | chpasswd

usermod -aG docker axxana

usermod -aG sudo axxana

sed -i ‘/PasswordAuthentication/d’ /etc/ssh/sshd_config ; echo “PasswordAuthentication no” >> /etc/ssh/sshd_config

sed -i ‘/PubkeyAuthentication/d’ /etc/ssh/sshd_config ; echo “PubkeyAuthentication yes” >> /etc/ssh/sshd_config

sed -i ‘/ChallengeResponseAuthentication/d’ /etc/ssh/sshd_config ; echo “ChallengeResponseAuthentication no” >> /etc/ssh/sshd_config

service ssh reload

Build a New Image

If you already have an image file, skip to the section below, titled Load Image.

In this step, we will create a new image from scratch, and then pack it at the end. Ensure you have the following file: \\nas\shared\oracle_tools\DockerASM\docker_asm_build_scripts.tar.gz

You can run /depo/ + /depo/ or you can run the following manual steps:

Prepare the Files

On Black Box as root:

scp docker_asm_build_scripts.tar.gz /tmp

mkdir /depo/

chown -R root:54422 /depo/

chmod 775 /depo

tar xvfz –same-owner /tmp/docker_asm_build_scripts.tar.gz -C /depo/

rm -f /tmp/docker_asm_build_scripts.tar.gz


List of the files



Runs for crontab to delete trace files periodically

Builds a docker image

Cleans all docker containers and an image


A crontab job script for grid users; deletes trace files periodically


An SQL script for listing disks

Checks docker images dependencies


Builds instruction for docker image

Exports a docker image and compresses it


Establishes settings for proper formatting of  SQL*Plus output


Grants database permission during the build process


The initialization file for ASM instance

Installs script for grid

Oracle 12.2 grid software (no patches)


Listener file


Logrotate for Oracle logfiles


Handy tool to enable history in SQL*Plus, asmcmd

Starts a container

Provides images and container status

Run the Build Image

On Black Box as root/axxana:

cd /depo/docker_folder

docker build -t ynixon/docker_grid_asm .

Run the image detached (at background):

docker run –rm –privileged –detach –name asm_grid_build -h gridserver -p 1521:1521 -p 2222:22 –shm-size 2048m -e TZ=UTC -v /sys/fs/cgroup:/sys/fs/cgroup:ro –volume /depo:/software –volume /boot:/boot –device=/dev/sdb1 ynixon/docker_grid_asm

Install the grid software:

docker exec -it asm_grid_build su – grid -c ‘/software/’

Save the image with the grid:

docker commit -m “oracle linux 7.5 standalone grid infrastructure with ASM” -a “Yossi Nixon <>” asm_grid_build ynixon/axxana_asm_server

Remove the intermediate image (without the grid):

docker rm -f asm_grid_build

Optional – Check the New Image

Run the container at the background:

docker run –privileged –detach –name asm_grid -h gridserver -p 1521:1521 -p 2222:22 –shm-size 2048m -e TZ=UTC -v /sys/fs/cgroup:/sys/fs/cgroup:ro –volume /depo:/software –volume /boot:/boot –device=/dev/sdb1 –restart always ynixon/axxana_asm_server

Connect to the new container to verify the environment:

docker exec -it –user grid asm_grid bash -l

Export the image and compress it:

docker save -o /depo/export/docker_axxana_asm_server.tar ynixon/axxana_asm_server:latest

gzip docker_axxana_asm_server.tar

Optional – Load the Image

Copy the file \\nas\shared\oracle_tools\DockerASM\docker_axxana_asm_server.tar.gz to /tmp

Uncompress the file:

gunzip /tmp/docker_axxana_asm_server.tar.gz

Load the file into the local container repository:

docker load -i /depo/export/docker_axxana_asm_server.tar

Run a container based on the loaded image:

docker run –privileged –detach –name asm_grid -h gridserver -p 1521:1521 -p 2222:22 –shm-size 2048m -e TZ=UTC -v /sys/fs/cgroup:/sys/fs/cgroup:ro –volume /boot:/boot –device=/dev/sdb1 –restart always ynixon/axxana_asm_server

Test connection from remote machines:

ssh root@<Black Box IP> -p 2222

sqlplus sys/axxana@<Black Box IP>:1521/+ASM as sysasm

Deploy web interface – Portainer:

$ docker volume create portainer_data

$ docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer

Open browser at: http://<docker server>:9000/