Connecting to Oracle instance running on Docker - oracle

I spent more than two days on this and I ran out of ideas and I really hope someone here will be able to help.
I am running docker on my Linux Fedora laptop.
[julian#julian-hp ~]$ docker -v
Docker version 18.06.1-ce, build e68fc7a
I loaded an oracle 12c image from another laptop (running Linux Ubuntu) and ran it using the following command:
docker run --name oracle_12c_201 -p 1521:1521 -p 5500:5500
-v /opt/dev/data/oracle/o12c_201_u02/:/opt/oracle/oradata
-e ORACLE_PWD=admin 12a359cd0528
The container gets created and is displayed as healthy when running docker ps:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
544917a88b6b 12a359cd0528 "/bin/sh -c '/bin/ba…" 2 days ago Up 2 days (healthy) 0.0.0.0:1521->1521/tcp, 0.0.0.0:5500->5500/tcp oracle_12c_201
However when I try to login to my running instance I am getting ORA-01017: Invalid username/password; logon denied message
All of the HOW TOs I found on the internet say that if you do not specify a password when you create the container using docker run the the SYS password will be displayed under this line:
ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN:
There is not such a line in my logs. Note I deleted the container using all possible permutations such following internet articles such as -e "ORACLE_PWD=admin" or not specifying a password at running docker run using sudo nothing worked.
When trying to change the password using below:
docker exec oracle_12c_201 ./setPassword.sh admin
It fails with the following error mesage:
OCI runtime exec failed: exec failed: container_linux.go:348: starting container
process caused "exec: \"./setPassword.sh\": stat ./setPassword.sh:
no such file or directory": unknown
I ran out of ideas. I can see from the logs that the database is up and running but it is useless as long as I cannot connect to it. Note that the same image runs OK and I can connect to it without any problems on my other laptop running Linux Ubuntu. Unfortunately I no longer have the commands that I used to install oracle on that machine.
Thank you in advance for your help.

Related

error credentials on gvenzl/oracle-xe ARM colima docker

I'm trying to run an Oracle database on mac m1Pro ARM, so far, here are the steps i did :
Uninstalled colima and docker:
brew uninstall colima docker
Uninstalled docker desktop and deleted all files related.
Installed colima and docker :
brew install colima docker
Ran this command to execute colima :
colima start --arch x86_64 --memory 4
Executed the docker run :
docker run -d -p 1521:1521 -e ORACLE_PASSWORD=azerty gvenzl/oracle-xe
Checked if my container was running :
docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8ffc237bc009 gvenzl/oracle-xe "container-entrypoin…" 4 seconds ago Up 1 second 0.0.0.0:1521->1521/tcp, :::1521->1521/tcp intelligent_williams
used the integrated commands as mentioned here in "Database users" part :
base : docker exec container name|id createAppUser your_app_user your_app_user_password [your target PDB]
I first tried that :
docker exec 8ffc237bc009 createAppUser oracle azerty XE
But the SID XE wasn't recognized by the listener, then I did that
(default target is said to be XEPDB1)
docker exec 8ffc237bc009 createAppUser oracle azerty
so far it returned that :
Session altered.
User created.
Grant succeeded.
I was pretty confident there, so I ran into DataGrip and did that:
Then this error happend:
At first I thought it was because of SID XEPDB1 so I just replaced it with XE and this error got to me, at this point I knew it was responding:
Now I can't figure it out because I checked if I was misstyping in caps or anything, tried multiple times to cmd+C and cmd+v to make sur, still wrong logons. if anyone has a clue, I'm up for it. if there is anything wrong with what I did, I would love to know !
AS Olga M answered in the comment of my post, the fix was to replace the URL string:
jdbc:oracle:thin:#localhost:1521:XEPDB1
or
jdbc:oracle:thin:#localhost:1521:XE
to 👇:
jdbc:oracle:thin:#localhost:1521/XEPDB1
hope my process helps ✅.
Thanks again Olga M !

How to use sqlldr on Oracle database inside a docker container?

I installed oracle db version 19c in my docker environment with the following command:
docker run --name oracle19c --network host -p 1521:1521 -p 5500:5500
-v /opt/oracle:/u01/oracle oracle/database:19.3.0-ee
Then I connect to it with:
docker exec -ti oracle19c sqlplus system/oracle#orclpdb1
SQL>
Then I setup my database. Afterwards I want to import dummy data from a tbl file so I exit sqlplus and I use the command:
sqlldr userid=system control=/home/userhere/sql_loader/control.ctl log=sf1customer.log
and get sqlldr: not found
I don't have much experience with Docker, but my research leads to me to believe that SQL *Loader does not come with the docker image. However, I do not know how to extend the image or where exactly I would call SQL *Loader even if I did. I am on a Ubuntu server and any help would be appreciated.
SQL*Loader is in the image - but the docker container is separate from your host OS, so ubuntu doesn't know any of the files or commands inside it exist. Any commands inside the container should be run as docker commands. If you try this, it should connect to your running container and print the help page:
docker exec -ti oracle19c sqlldr
Since you're running this command on the docker container, sqlldr doesn't have access to any of your host OS's files unless you specifically granted them to the container. But good news - when you started the database with docker run, that's what the -v /opt/oracle:/u01/oracle part of the command did - it mapped /opt/oracle on your Ubuntu filesystem to /u01/oracle in the docker container. So any files that you put in /opt/oracle will be available in the container under /u01/oracle.
So you'll need to do a couple things:
Your control.ctl file, log file, and whatever data file you're using need to be accessible to the container. Either move them to /opt/oracle or shutdown your database container and restart it with something like -v /home/userhere/sql_loader:/u01/oracle in the command.
You might also need to edit your control.ctl file to make sure that it doesn't reference any file paths on your host OS. Either use relative paths (./myfile.csv) or absolute paths with the container's filesystem (/u01/oracle/myfile.csv)
Now you should be able to run sqlldr on the container, and it should be able to access your data files.
docker exec -ti oracle19c sqlldr userid=system control=/u01/oracle/control.ctl log=/u01/oracle/sf1customer.log
Edit: Oh, I should mention - as an alternative, if you download and install the Oracle Instant Client in Ubuntu, you could run sqlldr locally in Ubuntu, and connect to the docker container over the network as a "remote" database:
sqlldr system#localhost:1521/orclpdb1 control=/home/userhere/sql_loader/control.ctl log=sf1customer.log
That way you don't have to move your files anywhere.

How to use oracle11g on Docker?

just now, i reinstall OSX on my macbook. Then i install Docker Desktop.
Because i want to use oracle database. But i encountered this logs.
Database is not installed. Installing...
Installation files not found. Unzip installation files into mounted(/install) folder
at first, i install SQL Developer. and in Terminal, i install jaspeen/oracle-11g by docker.
then, i run docker image.
$ docker run -d -p 59160:22 -p 59161:1521 jaspeen/oracle-11g
then, i typed
$ docker ps -l
but container's status is 'Exited (1) 16 seconds ago'
12750f964708 jaspeen/oracle-11g "/assets/entrypoint.…" 17 seconds ago Exited (1) 16 seconds ago busy_dewdney
if i have to install oracle database in ORACLE homepage?
I had the same issue and solved it by:
downloading "Linux x86-64" from https://www.oracle.com/database/technologies/oracle-database-software-downloads.htm
unzip both files into the same folder. In the end, you will have one single "database" folder where you had just unzip both files.
(just for the sake of the example you gave) move this folder (the "database" folder) into the "install_folder" folder
execute docker run --privileged --name oracle11g -p 1521:1521 -v path/to/your/install_folder:/install jaspeen/oracle-11g . The idea here is that the value you set for the "path/to/your/install_folder" to be the location of the folder that contains the "database" folder. In your case is it the "install_folder" folder. That -v flag is actually mounting your "install_folder" into docker container at "/install" location.
It will take a while until the process ends. It should first output the following:
Database is not installed. Installing...
Installing Oracle Database 11g
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 50321 MB Passed
Checking swap space: must be greater than 150 MB. Actual 856 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2020-03-30_08-00-03PM. Please wait ...
When you can connect to it with credentials below, then it is up&running:
username/password: SYS/oracle
SID: orcl
Note: I had tried more than one release from Oracle's download site until I found the lucky one. For example, in one situation the console just exited without any reason. When I typed docker ps, it showed that container exited with status 255 (which I did not find helpful).
I also found inspiration from here: https://programmer.group/install-oracle-11g-using-docker.html
Download database installation files from http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index-092322.html and unpack them to install_folder. Run container and it will install oracle and create database:
docker run --privileged --name oracle11g -p 1521:1521 -v :/install jaspeen/oracle-11g

Docker Postgres with windows share

I migrated from Linux to Windows and tried to setup a postgres container with a mounted directory (copied from my Linux install) containing the database.
This does not work.
Windows mounts are always owned by root
Postgres does not run under root
How to get this unholy combination to work?
You don't provide much details so it is difficult to tell what actually went wrong. However there is a known issue with Postgres setup on Windows Docker using a windows mount for database data files. In that case, running docker logs will show something along the following lines
waiting for server to start....FATAL: data directory "/var/lib/postgresql/data" has wrong ownership
HINT: The server must be started by the user that owns the data directory.
stopped waiting
pg_ctl: could not start server
Unfortunately there is no way to overcome this issue so you cannot use Windows mount, see Postgres Data has wrong ownership. You may use docker volumes in order to make database data indipendent from docker postgres container, using the following commands
docker create -v /var/lib/postgresql/data --name PostgresData alpine
docker run -p 5432:5432 --name yourPostgres -e POSTGRES_PASSWORD=yourPassword -d --volumes-from PostgresData postgres
You may find a more thoroughful explanation at Setup Postgresql on Windows with Docker

Docker on Win10 - is it possible to have multiple terminals?

I am new to Docker - installed DockerToolbox on Win10. And managed to run some basic docker examples. But I cannot seem to figure out how to access same container from multiple command line windows.
Quick online search suggested finding container ID (e.g. 2c7e29b9b666) via
docker ps
then running (I presume in new command window)
docker exec -it 2c7e29b9b666 bash
but that does not work in Win10.
Error message received is:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Edit: in the first window I started docker machine via:
docker-machine create --driver virtualbox tombox
and I can see 'tombox' in second window if I do:
docker-machine ls
Do I need to somehow reference 'tombox' when running docker commands in second window?

Resources