我有一个工作的oracle映像,我可以使用run,然后使用docker进入正在运行的容器并执行sqlplus命令,没有问题。
现在,我正在尝试使用这个图像创建一个新的图像,其中包含一些初始数据。这是我的码头文件。
FROM oracle:12.2
USER root
COPY /testingData /testingData
RUN chown -R oracle:oinstall /testingData
RUN chmod -R 755 /testingData
USER oracle
RUN /testingData/runInitSQLScript.sh
这是我的sh文件
#!/bin/bash
sqlplus -s /nolog << EOF
CONNECT sys as SYSDBA/testpass;
whenever sqlerror exit sql.sqlcode;
set echo off
set heading off
@/sql/mytestingData.sql
exit;
EOF
它一直告诉我sqlplus命令找不到
当我尝试像这个@ORACLE_HOME/bin/sqlplus
一样使用sqlplus的完整路径时,它仍然是一样的。然后我试着检查路径,我意识到我只能进入根目录下的一个层,例如,如果我的ORACLE_HOME是/u01/app/oracle/product/12.2.0/dbhome_1/
,我只能把cd
转到/u01
,当我做cd /u01/app
时,它开始说那个目录没有找到。请帮帮忙。谢谢。
发布于 2020-07-24 16:45:09
如果映像与官方映像类似,则只在容器启动后安装Oracle软件并创建数据库。因此,在创建图像时,ORACLE_HOME目录还不存在。如果出现官方图像,我建议您将脚本放在以下两个特殊文件夹中的一个:
-v /opt/oracle/scripts/startup | /docker-entrypoint-initdb.d/startup
Optional: A volume with custom scripts to be run after database startup.
For further details see the "Running scripts after setup and on startup" section below.
-v /opt/oracle/scripts/setup | /docker-entrypoint-initdb.d/setup
Optional: A volume with custom scripts to be run after database setup.
For further details see the "Running scripts after setup and on startup" section below.
有关此的更多信息:https://github.com/oracle/docker-images/tree/master/OracleDatabase/SingleInstance
发布于 2020-07-24 09:29:43
更新:如per @Sayan注释在$ORACLE_HOME/bin/sqlplus
路径上存在sqlplus。或
另一种选择是使用下面的停靠映像与Oracle database container
连接
docker run --interactive guywithnose/sqlplus sqlplus {CONNECTION_STRING}
或者使用遗留链接更好地使用docker网络。
docker run --it --link db guywithnose/sqlplus sqlplus {CONNECTION_STRING}
现在,您可以使用db
作为db连接的主机名。
https://stackoverflow.com/questions/63077259
复制相似问题