Docker / Oracle Database / Change Port 1521
NickName:Jean-Philippe M Ask DateTime:2021-09-20T23:47:39

Docker / Oracle Database / Change Port 1521

I have set an Oracle docker image (https://github.com/oracle/docker-images/tree/main/OracleDatabase/SingleInstance/dockerfiles) which by default is running on port 1521. I would like to change the port in the Image to 1531.

I know that in the docker-compose I can set "1531:1521" BUT the other container still searching for port 1521 in the created network.

I tried to modify the port referenced in the Dockerfile of the version I want to use (19.3.0) and also in the createDB.sh but when I try to connect with the SID it fails, the listener is not working as expected.

Anybody already succeeded?

Update 1: Here is the error message when I try to connect to the database after I changed the port.

SQL> CONNECT sys/HyperSecuredPassword@ORCLCDB AS sysdba; ERROR: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

Update 2: I have the following docker-compose.yaml to set up the other containers for my project.

version: "3.8"

services:

  hadea-database:
    image:  hadea_oracle_1521:19.3.0
    container_name: hadea_oracle_1930
    ports:
      - "1521:1521"
    environment:
      - ORACLE_SID=ORCLCDB
      - ORACLE_PDB=ORCLPDB
      - ORACLE_PWD=Oracle4System
      - ORACLE_MEM=2000
    volumes:
      - ./database/OracleDB/oradata:/opt/oracle/oradata
      - ./database/OracleDB/setup:/opt/oracle/scripts/setup
      - ./database/OracleDB/startup:/opt/oracle/scripts/startup
    networks:
      - hadea-network

  hadea-maildev:
    image: maildev/maildev
    container_name: hadea_maildev
    command: bin/maildev --web 80 --smtp 25 --hide-extensions STARTTLS
    ports:
      - "8081:80"
    networks:
      - hadea-network

  hadea-server:
    build:
      context: ./server
      dockerfile: Dockerfile
    container_name: hadea_back
    environment:
      - HTTP_PORT=3000
      - HTTP_HOST=0.0.0.0
      - DATABASE_HOST=hadea-database
      - DATABASE_PORT=1521 # CONTAINER port NOT the HOST port
      - DATABASE_SID=ORCLCDB
      - MAIL_HOST=hadea-maildev
      - MAIL_PORT=25 # CONTAINER port NOT the HOST port
    ports:
      - "3000:3000"
    working_dir: /usr/src/app
    volumes:
      - ./server:/usr/src/app
    networks:
      - hadea-network
    depends_on:
      - hadea-database
      - hadea-maildev

  hadea-front:
    build:
      context: ./front
      dockerfile: Dockerfile
    container_name: hadea_front
    ports:
      - "4200:4200"
      - "3001:3001"
    volumes:
      - ./front:/usr/src/app
    networks:
      - hadea-network
    depends_on:
      - hadea-database
      - hadea-maildev
      - hadea-server

networks:
  hadea-network:


Copyright Notice:Content Author:「Jean-Philippe M」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69257362/docker-oracle-database-change-port-1521

More about “Docker / Oracle Database / Change Port 1521” related questions

Docker / Oracle Database / Change Port 1521

I have set an Oracle docker image (https://github.com/oracle/docker-images/tree/main/OracleDatabase/SingleInstance/dockerfiles) which by default is running on port 1521. I would like to change the ...

Show Detail

How to change default port 1521 for oracle database?

I already have oracle 11g installed in my windows. I was trying to use oracle docker image. I downloaded Oracle Database Enterprise Edition image from docker hub using docker pull store/oracle/data...

Show Detail

oracle docker port conflict

Need your assistance please. created two containers on 19.3e but there is conflict when i open both the same time... docker run -d --name oracle1931 -p 1522:1521 -e ORACLE_PWD=password123 -v oradat...

Show Detail

Import Oracle dump tables to Oracle Database in docker

OS is Ubuntu 20.04. I have a Oracle Database 19c which is in docker. In details, In /opt, I create oracle folder with subfolders and give them grant. You see them in following: sudo chmod 777 /opt/...

Show Detail

Java unable to get a connection to Oracle database in a docker container

I'm working with an Oracle 19c instance in a Docker container. With DBeaver, i manage to connect to the database. But with the following Java code, i get the following error : TNS-12535: TNS:opera...

Show Detail

Oracle Database docker linux VM - Laptop connection

I have an Oracle database running in a Linux VM. The way i started the docker is using the following command sudo docker run -d --name my_db --net oac_net -p 1521:1521 -P --shm-size=4G bi.docker.

Show Detail

Docker Oracle Database - can't overwrite ENV variables for credentials

I would like to configure an Oracle database on a server. For that, I am using this image from DockerHub: https://hub.docker.com/r/sath89/oracle-12c/ Having included the image in a docker-compose.yml

Show Detail

How to stop oracle listening on port 1521(TNS)

There is a oracle xe edition installed on a machine. My requirement is to stop oracle from listening on the 1521 port. This port is used by the TNS system. Also i need to do this from a vb.net program

Show Detail

Oracle Database on Docker is very, very slow

I created one Oracle Database on Docker based on the instruction and dockerfile in the following website. https://github.com/oracle/docker-images/tree/master/OracleDatabase After image is created a...

Show Detail

Is there any extra step to connect oracle database running on docker to connect to sql developer?

I pulled the image from this docker pull store/oracle/database-enterprise:12.2.0.1 Also I can run the database by docker run -d -it --name <Oracle-DB> store/oracle/database-enterprise:12.2.0....

Show Detail