Docker 上的 Oracle :: ORA-12162: TNS:net 服务名称指定不正确 [英] Oracle on Docker :: ORA-12162: TNS:net service name is incorrectly specified

查看:113
本文介绍了Docker 上的 Oracle :: ORA-12162: TNS:net 服务名称指定不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次在 Oracle Docker 映像上登录 sqlplus 时,我都必须设置 $ORACLE_SID.

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

重现步骤:

  1. 我登录到一个从 Oracle 新下载并安装的全新 19c 映像:docker exec -it 19c bash
  2. 我检查了 $ORACLE_SID 并且命令 echo $ORACLE_SID 返回一个空行(很奇怪!?)
  3. 所以我手动设置了 $ORACLE_SID:export ORACLE_SID="ORCLCDB"
  4. 我再次检查了 $ORACLE_SID,这次命令 echo $ORACLE_SID 返回给我 ORCLCDB 这是我设置的正确名称
  5. 我使用 exit
  6. 从 bash Docker 终端退出
  7. 我重新登录 docker exec -it 19c bash
  8. 我检查 $ORACLE_SID 是否与 echo $ORACLE_SID 一起保存,它再次返回一个空行
  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

为什么更改不是永久性的?

Why the change is not permanent?

推荐答案

一旦容器启动,no 就无法更改/添加环境变量.因此,最好的选择是停止并删除现有容器,然后使用正确的环境变量重新创建它.在 Docker 中,您可以使用 Dockerfile 中的 ENV 命令在图像上设置环境变量.也可以配置调用docker run -e ...

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 ...

这篇关于Docker 上的 Oracle :: ORA-12162: TNS:net 服务名称指定不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆