Hi,
Why does my dockerfile keeps throwing the below error where i am simply doing a sqlplus command using the db service in the docker-compose so that it connects to the same container.
The same command works when on the container.
Any thoughts…
I’m not sure but using the CMD that way is usually not recommended. You can learn about the reasons here:
You should create a start script and run like this:
CMD ["/start.sh"]
The content of the start script could be:
#!/bin/sh
exec sqlplus sys/password123@db:1521/ORCLPDB1 as sysdba @/tmp/utPLSQL/source/install_headless.sql
Or I gues you would like to use environment variables instead of setting the password the way you tried in your quoted code.
Of course you don’t have to always create a start script, but it helps sometimes so you can have any shell you define in the first line if the command requires bash or anything else. And exec is important usually. In your case since the command runs and stops, it is not so important but doesn’t hurt.
ive incorporated the execution of script in the docker-compose as appose to using a dockerfile. This way we can use depend_on to wait for the db build and then execute the script.
If you mark your own post as solution, please also share the solution so other users can solve it too. “another way” itself is not a solution Thank you!