Docker-images: Cannot connect from to Oracle 18 XE from host

Created on 13 Mar 2020  路  8Comments  路  Source: oracle/docker-images

I am trying to connect to the SYS user as sysdba from outside the Docker container using the following command from Readme.md:
sqlplus sys/<your password>@//localhost:1521/XE as sysdba

However, when I put in the password I chose while starting the Docker container it always gives me error ORA-01017 invalid username/password.

If I use docker exec and call su -p oracle -c "sqlplus / as sysdba" login works as expected. With docker exec I can also login to the PDB with sqlplus pdbadmin/<your password>@//localhost:1521/XEPDB1.

What do I have to do to be able to login as sysdba from outside the Docker container without using docker exec so I can use SQL Developer, for example?

database question

Most helpful comment

Hi! Bumped into the same issue.
After some investigation I found out following:

  • Connecting via / as sysdba succeds when using docker exec
  • Connecting via sys/<yourpass> as sysdba fails with ORA-01017
  • Connecting via / as sysdba and querying v$pwfile_users returns no rows
  • As told by ID 730067.1 orapw-file should have oracle:oinstall user and group respectively. In this case it's root:root. After manual removing symlink and creating orapw-file I managed to connect to DB using sys password.
  • Also I didn't managed to pass a complex password (meaning characters like !?@) to ORACLE_PWD variable when running via docker-compose command. In this case I see infinitely running messages about password cannot be null or something. I wanted to do this because orapwd utility doesn't allow to create an orapw-file if your password is weak.

I hope it will help to solve an issue.

All 8 comments

Hi @HKnackstedt,

As you are receiving an ORA-01017 invalid username/password and the user looks correct (SYS), I assume that you are using an invalid password.

The docker exec that you have stated above uses a passwordless authentication / as sysdba, which btw only works on the database server.

Can you double-check your password, please, and see whether docker exec -ti <container name> su -p oracle -c "sqlplus sys/<your password>//localhost:1521/XE as sysdba" works?

Thx,

Hi! Bumped into the same issue.
After some investigation I found out following:

  • Connecting via / as sysdba succeds when using docker exec
  • Connecting via sys/<yourpass> as sysdba fails with ORA-01017
  • Connecting via / as sysdba and querying v$pwfile_users returns no rows
  • As told by ID 730067.1 orapw-file should have oracle:oinstall user and group respectively. In this case it's root:root. After manual removing symlink and creating orapw-file I managed to connect to DB using sys password.
  • Also I didn't managed to pass a complex password (meaning characters like !?@) to ORACLE_PWD variable when running via docker-compose command. In this case I see infinitely running messages about password cannot be null or something. I wanted to do this because orapwd utility doesn't allow to create an orapw-file if your password is weak.

I hope it will help to solve an issue.

@gvenzl The password is correct. I tried setting it explicitly or using a generated one, both do not work when using the method I described.

As @alesana-san explained, it is not possible to login using "sys/".

How do I create a orapw-file with correct ownership? I tried using "chown" command but it does not work.

Hm, curious, I can't reproduce that behavior on a freshly created container:

[oracle@ol7 ~]$ docker run -d --name oracle-xe -p 1521:1521 -v oracle-xe:/opt/oracle/oradata -e ORACLE_PWD=LetsDocker1 oracle/database:18.4.0-xe
11faeee8e64c90b9dd9cc78d5cd9ecf254368b035cfb8b632011a1128c1df94e
[oracle@ol7 ~]$ docker logs -f oracle-xe
ORACLE PASSWORD FOR SYS AND SYSTEM: LetsDocker1
Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts:
Confirm the password:
Configuring Oracle Listener.
Listener configuration succeeded.
Configuring Oracle Database XE.
Enter SYS user password:
***********
Enter SYSTEM user password:
************
Enter PDBADMIN User Password:
***********
Prepare for db operation
7% complete
Copying database files
29% complete
Creating and starting Oracle instance
30% complete
31% complete
34% complete
38% complete
41% complete
43% complete
Completing Database Creation
47% complete
50% complete
Creating Pluggable Databases
54% complete
71% complete
Executing Post Configuration Actions
93% complete
Running Custom Scripts
100% complete
Database creation complete. For details check the logfiles at:
 /opt/oracle/cfgtoollogs/dbca/XE.
Database Information:
Global Database Name:XE
System Identifier(SID):XE
Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE.log" for further details.

Connect to Oracle Database using one of the connect strings:
     Pluggable database: 11faeee8e64c/XEPDB1
     Multitenant container database: 11faeee8e64c
Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE
The Oracle base remains unchanged with value /opt/oracle
#########################
DATABASE IS READY TO USE!
#########################
The following output is now a tail of the alert.log:
Pluggable database XEPDB1 opened read write
Completed: alter pluggable database XEPDB1 open
2020-03-16T23:29:06.831729+00:00
XEPDB1(3):CREATE SMALLFILE TABLESPACE "USERS" LOGGING  DATAFILE  '/opt/oracle/oradata/XE/XEPDB1/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED  EXTENT MANAGEMENT LOCAL  SEGMENT SPACE MANAGEMENT  AUTO
XEPDB1(3):Completed: CREATE SMALLFILE TABLESPACE "USERS" LOGGING  DATAFILE  '/opt/oracle/oradata/XE/XEPDB1/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED  EXTENT MANAGEMENT LOCAL  SEGMENT SPACE MANAGEMENT  AUTO
XEPDB1(3):ALTER DATABASE DEFAULT TABLESPACE "USERS"
XEPDB1(3):Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS"
2020-03-16T23:29:08.549418+00:00
ALTER PLUGGABLE DATABASE XEPDB1 SAVE STATE
Completed: ALTER PLUGGABLE DATABASE XEPDB1 SAVE STATE
^C

Run SQLcl from the host:

[oracle@ol7 ~]$ sql sys/LetsDocker1@//localhost:1521/XE as sysdba

SQLcl: Release 19.4 Production on Mon Mar 16 23:35:35 2020

Copyright (c) 1982, 2020, Oracle.  All rights reserved.

Connected to:
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0


SQL>

Hi! I guess the issue is connected with host OS. I see your host OS is linux and in that case I think your orapw has oracle:oinstall while all replied people have windows host and we have root:root.

I can confirm that. I am also using a Windows host.

This is a known issue with Docker for Windows given it uses SMB/CIFS to mount the file system inside the hidden Linux VM in which Docker runs. You may have some luck using a custon volume as per https://github.com/moby/moby/issues/37161#issuecomment-392511903 to mount your Windows file system with the right permissions to create the Docker image.

Indeed, I'm using Linux and a Mac but not Windows.

Sounds like this the same issue reported in #525

Was this page helpful?
0 / 5 - 0 ratings