As I am an Oracle consultant I sometimes want to try things on a local instance. My normal way of working is to fire up a virtual machine or docker instance with the Oracle database and try the things I want to try.
As I bought a new laptop and selected a new MacBook Pro with an M2 processor, the docker method does not work anymore. And firing up a virtual machine is a bit more complicated as I used to have an Intel based MacBook (my laptops last for quite some time).
There is, however, a workaround….
Install UTM and create a virtual machine with emulation. I used the approach to install Docker within the machine to run the Oracle Database as an container.
First we need to get and install UTM. This can be done in two ways, via the AppStore or downloading UTM from https://mac.getutm.app . Both methods give you the exact same software, only if you use the AppStore you support the project itself as you need to pay for it.
Once we have installed the software we can create an emulated machine on which we run the Oracle Database.
I’ve created an older type of machine (i440FX + PIIX) as it seemed to work best. The “System” configuration of my virtual machine:
It’s simple 4 core machine with 4GB of memory with no further bells and whistles. The Linux installation within the machine itself is Debian (Intel).
Next step is installing docker-compose via apt. (apt install docker-compose)
If all went well we can build an image that contains the Oracle Database of our choosing or migrate one from another host.
To build the image, head to https://github.com/oracle/docker-images and clone the repo. With it you can build the database of your choosing. I’ve built an image with the 21c Database by downloading the binaries from the Oracle website and building the image by means of the buildContainerImage.sh command (buildContainerImage.sh -v 21.3.0 -e -t oracledb:21c)
Once the image has been created we can start a database container with the following docker-compose.yml.
version: '2' services: db: image: oracledb:21c restart: always volumes: - /opt/DockerData/Oracle/containers/21c/oradata:/opt/oracle/oradata ports: - 1521:1521 - 8090:8090
Make sure you create the data folder beforehand and run a chmod 777 and a chmod +t on it as the Oracle Database will not be running as root. If you don’t do this the container will fail to create the new database as it will not be able to store the datafiles.
Bring the container up with a simple docker-compose up and after a bit of time (first startup the container will start to create a new database) we are greeted with the message the database is ready to use:
If it’s the first time you’ve started the container and don’t know which passwords are being used start a shell within the container (docker-compose exec db bash) and run the setPassword.sh shell script to set the passwords to something you know.
And then it’s just a matter of firing up SQLDeveloper and logging into the database
As the machine is run via emulation the performance won’t be as good as it would run natively, but for the things I’m using it for the performance of the database is good enough (it runs quite fast). YMMV though.