top of page
  • Writer's pictureTawatchai

Set up an Oracle Database using Docker Compose with the official Oracle Database container image

To set up an Oracle Database using Docker Compose with the official Oracle Database container image, follow these steps:

  • Install Docker and Docker Compose:

    • Install Docker on your machine by following the instructions provided for your operating system. Visit the Docker website (https://www.docker.com/) to download and install Docker.

    • Install Docker Compose by following the installation instructions specific to your operating system. Visit the Docker Compose documentation (https://docs.docker.com/compose/install/) for more information.

  • Download the Oracle Database Docker Image:

    • Visit the Oracle Container Registry (https://container-registry.oracle.com/) and create an account if you don't have one already.

    • Accept the license agreement and browse the available Docker images for Oracle Database.

    • Select the appropriate Oracle Database version and edition you want to use and download the corresponding Docker image.


  • Create a Docker Compose file:

    • Create a new file called docker-compose.yml in a directory of your choice.

    • Open the docker-compose.yml file in a text editor and add the following contents:


version: '3'
services:
  oracle-db:
    image: oracle/database:18.4.0-xe
    ports:
      - 1521:1521
    environment:
      - ORACLE_SID=XE
      - ORACLE_PDB=XEPDB1
      - ORACLE_PWD=mysecretpassword
    volumes:
      - ./data:/opt/oracle/oradata

In this example, the Docker Compose file specifies a service named oracle-db using the official Oracle Database container image oracle/database:18.4.0-xe. It maps the container's port 1521 to the host machine's port 1521. It also sets environment variables for the Oracle System Identifier (SID), Oracle Pluggable Database (PDB) name, and password for the administrative accounts. The volumes section maps the Oracle database data directory to the ./data directory on the host machine.

  • Start the Docker container:

    • Open a terminal or command prompt.

    • Navigate to the directory where the docker-compose.yml file is located.

    • Run the following command to start the container:


docker-compose up -d

Docker Compose will read the configuration from the docker-compose.yml file and start the Oracle Database container in detached mode (-d).

  • Wait for Initialization:

    • Wait for the Docker container to initialize Oracle Database, which may take several minutes. You can monitor the initialization progress in the container logs using the docker-compose logs command:


docker-compose logs -f

  • Connect to the Oracle Database:

    • Once the container is initialized, you can connect to the Oracle Database using a client tool or programming language with the following connection details:

      • Host: localhost

      • Port: 1521 (or the mapped port you specified in the docker-compose.yml file)

      • SID: XE

      • PDB: XEPDB1

      • Username: SYS or SYSTEM

      • Password: The password you set in the docker-compose.yml file (e.g., "mysecretpassword")


That's it! You have now set up an Oracle Database using Docker Compose with the official Oracle Database container image. You can start using the Oracle Database for your development or testing purposes. To stop the container, you can run docker-compose down in the same directory as the docker-compose.yml file.








31 views0 comments

Recent Posts

See All

Comments


bottom of page