Oracle 12c docker setup on Apple M1

Viewed 16230

I am trying to run Oracle db in docker on M1 Mac. I have tried images from both store/oracle/database-enterprise:12.2.0.1-slim and container-registry.oracle.com/database/enterprise:12.2.0.1-slim but getting the same error.

docker run -d -it --name oracle -v $(pwd)/db/oradata:/ORCL store/oracle/database-enterprise:12.2.0.1-slim

I also tried non-slim version and by providing the --platform linux/amd64 to the docker command. Result is same.

Here's the result of docker logs -f oracle

Setup Oracle Database
Oracle Database 12.2.0.1 Setup
Sat Jul 31 18:44:14 UTC 2021

Check parameters ......
log file is : /home/oracle/setup/log/paramChk.log
paramChk.sh is done at 1 sec

untar DB bits ......
log file is : /home/oracle/setup/log/untarDB.log
untarDB.sh is done at 29 sec

config DB ......
log file is : /home/oracle/setup/log/configDB.log
Sat Jul 31 18:44:42 UTC 2021
Start Docker DB configuration
Call configDBora.sh to configure database
Sat Jul 31 18:44:42 UTC 2021
Configure DB as oracle user
Setup Database directories ...

SQL*Plus: Release 12.2.0.1.0 Production on Sat Jul 31 18:44:43 2021

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

ERROR:
ORA-12547: TNS:lost contact


Enter user-name: SP2-0306: Invalid option.
Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] [edition=value]]
where <logon> ::= <username>[/<password>][@<connect_identifier>]
      <proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]
Enter user-name: Enter password: 
ERROR:
ORA-12547: TNS:lost contact


SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
update password

Enter password for SYS: 
create pdb : ORCLPDB1

SQL*Plus: Release 12.2.0.1.0 Production on Sat Jul 31 18:44:43 2021

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

ERROR:
ORA-12547: TNS:lost contact


Enter user-name: SP2-0306: Invalid option.
Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] [edition=value]]
where <logon> ::= <username>[/<password>][@<connect_identifier>]
      <proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]
Enter user-name: SP2-0306: Invalid option.
Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] [edition=value]]
where <logon> ::= <username>[/<password>][@<connect_identifier>]
      <proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]
SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
Reset Database parameters

SQL*Plus: Release 12.2.0.1.0 Production on Sat Jul 31 18:44:43 2021

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

ERROR:
ORA-12547: TNS:lost contact


Enter user-name: SP2-0306: Invalid option.
Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] [edition=value]]
where <logon> ::= <username>[/<password>][@<connect_identifier>]
      <proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]
Enter user-name: Enter password: 
ERROR:
ORA-12547: TNS:lost contact


SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 31-JUL-2021 18:44:44

Copyright (c) 1991, 2016, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/12.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/989db909d8df/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=0.0.0.0)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                31-JUL-2021 18:44:44
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/989db909d8df/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

DONE!
Remove password info
Docker DB configuration is complete !
ERROR : config DB failed, please check log /home/oracle/setup/log/configDB.log for details!
OS process OFSD (ospid 188) idle for 30 seconds, exiting
2017-08-09T10:36:20.752530+00:00
ARCH: Archival disabled due to shutdown: 1090
Shutting down archive processes
Archiving is disabled
JIT: pid 563 requesting stop
2017-08-09T10:36:20.815635+00:00
Stopping background process VKTM
2017-08-09T10:36:26.581058+00:00
Instance shutdown complete (OS id: 563)
/usr/bin/tail: inotify cannot be used, reverting to polling: Function not implemented

Is it the issue with M1 or I my configuration

4 Answers

Oracle Database on M1 Mac

This is a doozy.. Oracle Database isn't supported on MacOS, however, with Docker virtualizing linux, it can be. Unfortunately, even though Docker supports M1 Mac ARM virtualization, Oracle Database relies heavily on some low level kernel calls that Docker and Rosetta 2 can't handle. This leads us to the only possible solution to run locally: Using full emulation (a virtual machine).

  1. Install Lima with HomeBrew. Lima is a sort of unofficial "macOS subsystem for Linux" with support for running VMs with different architecture (like running an x86 OS on top of ARM MacOS):
brew install lima
  1. Create a new Impish Ubuntu (default) Virtual Machine:
limactl start
  1. Select Open an editor to override the configuration.
  2. Using the default editor (vi) modify the arch field to the following (i to enter insert mode, make the change, ESC to enter command mode, :wq to exit and save).
arch: "x86_64"
  1. Run the newly created default Lima VM, and change directories to the new VM's home directory. (All commands past this should be run in the newly started shell unless specified otherwise).
lima
cd ~
  1. Install Docker for Ubuntu in the Lima VM.
  2. Add your user to the docker group, and activate the changes to be able to run docker commands without root access:
sudo usermod -aG docker $USER
newgrp docker
  1. Run Image from docker hub
docker login
docker run -d -p 1521:1521 --name oracle store/oracle/database-enterprise:12.2.0.1
  1. Connect with default values
username/password@SID: sys/Oradoc_db1@ORCLCDB

If someone is still struggling with this one, I found a better and straight forward solution:

  1. Install homebrew
  1. Install Colima
  • brew install colima
  1. Install docker
  • brew install docker
  1. Start Colima by setting up x86_64 architecture
  • colima start --memory 8 --arch x86_64
  1. Test docker
  • docker run hello-world

Note: You should clean everything related to docker from your system along with docker desktop, with this you do not need docker desktop

After investing some time on it, here is what I tested and worked and didn't work for me.

  • Lima - For me it didn't work. From what I got, Lima is a qemu wrapper. So in theory it should work, but I had same problems as the ones described on this open issue: https://github.com/lima-vm/lima/issues/713#issuecomment-1064151675

  • Multipass - Didn't work. Multipass is an Ubuntu's vm. The problem is that it does not support cross architecture for now. You will only be able to create vms for the same architecture (aarch64) and oracle won't run on it.

  • Qemu directly. This is the only option that worked for me, if you are interested on the steps here it is:

  1. brew install qemu utm

obs.: utm is a graphical tool to run qemu without having to know its complicated commands.

  1. Download an amd64 linux iso of your preference.

In my case it was an ubuntu server (just make sure it is for amd64)

  1. On utm create a new emulator and select the image you downloaded

I've selected for the machine architecture the first one available (label with 2009), there is one tagged with a (default) but it is too slow - avoid this one.

2 cores for cpu, 4G mem was enough for me.

For the shared folder, it is not a very straight forward the way to access it, so in the end scp was enough for file transfer between host/guest machines.

  1. Once you have passed the installation process and have logged in, install docker:

https://docs.docker.com/engine/install/ubuntu/

extra: sudo apt-get install docker-compose

  1. Load your oracle docker image and run it.

If you have any volume configured you need to remember to give access permission to it (chmod)

  1. Enjoy :)

There are two issues here:

  1. Oracle Database is not supported on ARM processors, only Intel. See here: https://github.com/oracle/docker-images/issues/1814
  2. Oracle Database Docker images are only supported with Oracle Linux 7 or Red Hat Enterprise Linux 7 as the host OS. See here: https://github.com/oracle/docker-images/tree/main/OracleDatabase/SingleInstance

Oracle Database ... is supported for Oracle Linux 7 and Red Hat Enterprise Linux (RHEL) 7. For more details please see My Oracle Support note: Oracle Support for Database Running on Docker (Doc ID 2216342.1)

The referenced My Oracle Support Doc ID goes on to say that the database binaries in their Docker image are built specifically for Oracle Linux hosts, and will also work on Red Hat. That's it.

Because Docker provides process level virtualization it still pulls kernel and other OS libraries from the underlying host OS. A Docker image built for Oracle Linux needs an Oracle Linux host; it doesn't bring the Oracle Linux OS with it. Only Oracle Linux or Red Hat Linux are supported for any Oracle database Linux installation, with or without Docker. Ubuntu, Mac OS, Debian, or any other *NIX flavor will not provide predictable reliable results, even if it is hacked into working or the processes appear to work normally.

Related