On this page

Skip to content

Setting up an Oracle Environment with Windows Docker Desktop

Previously, the official Oracle image was available on Docker Hub, but it is no longer provided for download. If you want to install Oracle using Docker, you must use a version provided by others or download the relevant resources from Oracle GitHub to build the image. This article uses the second method.

Prerequisites

  1. Currently, it is only provided for Linux Container environments.
  2. The Windows environment must be able to execute a Linux Bash Shell. You can use one of the following two methods:
    • Use Git Bash.
    • Windows 10 has it built-in. Open "Command Prompt" and type bash. If the command cannot be executed, please refer to this article.

Installation Steps

  1. Download the Dockerfile and related files.

  2. Open the file "Location/OracleDatabase/SingleInstance/dockerfile/{version}/Dockerfile", search for the keyword INSTALL_FILE_1, and check the files required for installation. If you want to install the XE version, check "Dockerfile.xe".

  3. Download the installation files to the version folder. You can refer to the notes in the Dockerfile for download locations. For example:

    text
    # (1) db_home.zip
    #     Download Oracle Database 19c Enterprise Edition or Standard Edition 2 for Linux x64
    #     from http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
    #
  4. Open bash and move the command directory to "Location/OracleDatabase/SingleInstance/dockerfile/".

  5. Enter the command to build the image. The command format is ./buildContainerImage.sh -v [version] -t [image_name:tag] [-e | -s | -x] [-i] [-o] [container build option]. The parameter descriptions are as follows:

    • -v: Set the version number corresponding to the folder name.
    • -t: Set the Tag for the docker-image.
    • -e: Generate an image for "Enterprise Edition" installation. Requires a version with "Dockerfile" or "Dockerfile.ee".
    • -s: Generate an image for "Standard Edition 2" installation. Requires a version with "Dockerfile" or "Dockerfile.se2".
    • -x: Generate an image for "Express Edition" installation. Requires a version with "Dockerfile.xe".
    • -i: Ignore "MD5 checksums" check.
    • -o: Input container build parameters, e.g., "'--build-arg SLIMMING=false'".
    text
    ./buildContainerImage.sh -e -v 21.3.0 -o '--build-arg SLIMMING=false'
  6. Generally, you do not need to use -o. If you encounter a failure due to "MD5 checksums" errors, you can add -i.

  7. If an error occurs stating that the image does not exist, open "dockerfile{[|.ee|.se2|.xe]}", search for the keyword FROM oraclelinux to check the image tag used, then go to Oracle Docker Hub to check if the tag exists. Change it to an existing tag; currently, you should use "7-slim".

  8. Wait for the image build to complete; this will take some time.

  9. Create a docker-compose file as follows (please replace the content in curly braces with your own settings):

    text
    version: '3.7'
    
    services:
      TP-Oracle:
        image: oracle/database:{image tag}
        container_name: TP-Oracle
        ports:
          - 1521:1521
          - 5500:5500
          - 8080:8080
        volumes:
          - {local oradata}:/opt/oracle/oradata
          - {local scripts/startup}:/opt/oracle/scripts/startup
          - {local scripts/setup}:/opt/oracle/scripts/setup
        restart: always
        environment:
          - ORACLE_PWD={your password}
          - ORACLE_CHARACTERSET=AL32UTF8
  10. Wait for the container to finish setting up. This takes a long time. If you are unsure when it is finished, you can open "Docker Dashboard" to view the container logs.

Creating a User

  1. Open a database management tool, such as "Oracle SQL Developer" or "sqlplus". Enter username: SYS, password as set in the docker-compose ORACLE_PWD, and role: sysdba.
  2. When creating a user, using all uppercase for the username is less likely to cause issues. Passwords are case-sensitive.
  3. Grant the user "connect", "resource", and "unlimited tablespace". If you have other requirements, you can add other permissions.
  4. For versions 12c and above, because there is a distinction between CDB and PDB, if you encounter "ORA-01017 invalid username/password; logon denied" when creating a user, please follow these steps:
    1. Execute the SQL command show pdbs to check the PDB name, usually "ORCLPDB1" or "XEPDB1".
    2. Execute the SQL command ALTER SESSION SET CONTAINER={PDB Name} to switch the container to the PDB database.
    3. Re-create the user and set role permissions.
    4. When logging in with the new user, you should use SERVICE_NAME={PDB Name} instead of SID={CDB Name}, or modify the "TNSNAMES.ORA" settings.

Actual Installation Experience

At this stage, installing 11g and 12c XE versions both have folder permission issues, causing the container to fail to run properly. The 19c SE2 version appears to work normally. When the computer or Docker restarts, you may find that the newly created user is missing when the Oracle Server first starts. This is because the PDB database mounts slowly; wait a while and it will appear.

Change Log

  • 2022-10-24 Initial document creation.