This article explains how to create and use a Docker container with an Oracle XE database on macOS. The following steps are very simple and easy. The database setup needs only minutes and works very well for development and testing purposes.
- Docker software for macOS is installed and configured (Download Docker for Mac).
Create and Configure the container
1. Navigate to github to get official Docker images for Oracle Software
2. Clone the git repository
git clone https://github.com/oracle/docker-images.git
3. Download the Oracle XE software from Oracle Technology Network
4. Copy the downloaded file into the folder
5. Build the Oracle XE Docker Image (see documentation for more details):
./buildDockerImage.sh -v 220.127.116.11 -x -i
6. Verify the existence of the new image
7. Start a new container with an Oracle XE database
docker run --name OracleXE --shm-size=1g -p 1521:1521 -p 8080:8080 -e ORACLE_PWD=weblogic1 oracle/database:18.104.22.168-xe
- Add -v option to the command to specify the data volume to use for the database. Has to be owned by the Unix user „oracle“ or set appropriately. If omitted the database will not be persisted over container recreation.
Use the Oracle XE container
1. Stop the container with
docker stop <container id> or start it with
docker start <container id>.
2. Connect to the database from macOS using localhost, port 1521 and SID XE. When using another VM on your macOS (example: a JDeveloper environment managed with vagrant) you have to use the IP address of you macOS system instead of localhost when connecting to the database.