Francesco Mantovani
Francesco Mantovani

Reputation: 12197

Oracle on Docker :: ORA-12162: TNS:net service name is incorrectly specified

I have to setup the $ORACLE_SID every time I login into sqlplus on Oracle Docker image.

Steps to reproduce:

  1. I login into a brand new 19c image freshly downloaded and installed from Oracle: docker exec -it 19c bash
  2. I check $ORACLE_SID and the command echo $ORACLE_SID return me an empty line (very strange!?)
  3. So I setup the $ORACLE_SID manually: export ORACLE_SID="ORCLCDB"
  4. I check again the $ORACLE_SID and this time the command echo $ORACLE_SID returns me ORCLCDB which is the right name I setup
  5. I exit from the bash Docker terminal with exit
  6. I log back in docker exec -it 19c bash
  7. I check if the $ORACLE_SID has been kept with echo $ORACLE_SID and it returns me an empty line again

enter image description here

Why the change is not permanent?

Upvotes: 3

Views: 4565

Answers (1)

Ratish Bansal
Ratish Bansal

Reputation: 2442

Once the container is started, there's no way to change/add the environment variable. Therefore, the best option is to stop and remove the existing container, then recreate it with the correct environment variable. In Docker, you can set the environment variable on an image with an ENV command in the Dockerfile. You can also configure the default environment used to start the container when you call docker run -e ...

Upvotes: 4

Related Questions