How do I connect to docker Oracle instance How do I connect to docker Oracle instance oracle oracle

How do I connect to docker Oracle instance


I've encountered this with those images, too. You will first have to open the pluggable database before you can connect to it.

I do that with something like this:

docker exec -ti oracle sqlplus / as sysdbaalter pluggable database pdb1 open;


Yes, I got the same error after setting up Oracle database in docker too.

So first check the instance is running (and look for the ORACLE_SID):

enter image description here

The Oracle SID is ORCLCDB.

If you don't have the environment set for ORACLE_SID, you get:

enter image description here

Connection failed.

But after you set your ORACLE_SID:

enter image description here

And now you no longer get the connection failure error, but a different SYSDBA instead.

Just add "/ as sysdba" to your entire sqlplus command and you are good to go.


Once the container has been started and the database created you can connect to it just like to any other database by one of the following methods:

1) sqlplus sys/<your password>@//localhost:1521/<your SID> as sysdba2) sqlplus system/<your password>@//localhost:1521/<your SID>3) sqlplus pdbadmin/<your password>@//localhost:1521/<Your PDB name>

Running SQL*Plus in a Docker container

You may use the same Docker image you used to start the database, to run sqlplus to connect to it, for example:

docker run --rm -ti oracle/database:12.2.0.1-ee sqlplus pdbadmin/<yourpassword>@//<db-container-ip>:1521/ORCLPDB1

Another option is to use docker exec and run sqlplus from within the same container already running the database:

docker exec -ti <container name> sqlplus pdbadmin@ORCLPDB1

To run your Oracle Database Docker image use the docker run command as follows:

docker run --name <container name> \-p <host port>:1521 -p <host port>:5500 \-e ORACLE_SID=<your SID> \-e ORACLE_PDB=<your PDB name> \-e ORACLE_PWD=<your database passwords> \-e ORACLE_CHARACTERSET=<your character set> \-v [<host mount point>:]/opt/oracle/oradata \oracle/database:12.2.0.1-eeParameters:   --name:        The name of the container (default: auto generated)   -p:            The port mapping of the host port to the container port.                   Two ports are exposed: 1521 (Oracle Listener), 5500 (OEM Express)   -e ORACLE_SID: The Oracle Database SID that should be used (default: ORCLCDB)   -e ORACLE_PDB: The Oracle Database PDB name that should be used (default: ORCLPDB1)   -e ORACLE_PWD: The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated)   -e ORACLE_CHARACTERSET:                  The character set to use when creating the database (default: AL32UTF8)   -v /opt/oracle/oradata                  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.   -v /opt/oracle/scripts/startup | /docker-entrypoint-initdb.d/startup                  Optional: A volume with custom scripts to be run after database startup.                  For further details see the "Running scripts after setup and on startup" section below.   -v /opt/oracle/scripts/setup | /docker-entrypoint-initdb.d/setup                  Optional: A volume with custom scripts to be run after database setup.                  For further details see the "Running scripts after setup and on startup" section below.

useful: https://github.com/oracle/docker-images/tree/master/OracleDatabase