给我一个docker部署oracle的dockerfile,以及启动命令
时间: 2024-06-11 12:06:12 浏览: 171
以下是一个Dockerfile,用于在容器中部署Oracle数据库。
```
FROM oraclelinux:7-slim
# Install required packages
RUN yum -y install oracle-release-el7 oracle-nodejs-release-el7 && \
yum-config-manager --enable ol7_oracle_instantclient && \
yum -y install oracle-instantclient19.3-basic oracle-instantclient19.3-sqlplus oracle-instantclient19.3-devel wget unzip && \
rm -rf /var/cache/yum
# Download Oracle Database 19c software
RUN mkdir /opt/oracle && \
cd /opt/oracle && \
wget -q https://download.oracle.com/otn/linux/oracle19c/19000/linuxx64_193000_db_home.zip && \
unzip linuxx64_193000_db_home.zip && \
rm -f linuxx64_193000_db_home.zip && \
cd /opt/oracle/database && \
./runInstaller -silent -ignorePrereq -waitforcompletion \
oracle.install.option=INSTALL_DB_SWONLY \
ORACLE_HOSTNAME=localhost \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=/opt/oraInventory \
SELECTED_LANGUAGES=en,en_GB \
ORACLE_HOME=/opt/oracle/product/19c/dbhome_1 \
ORACLE_BASE=/opt/oracle \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSOPER_GROUP=dba \
oracle.install.db.OSBACKUPDBA_GROUP=dba \
oracle.install.db.OSDGDBA_GROUP=dba \
oracle.install.db.OSKMDBA_GROUP=dba \
oracle.install.db.OSRACDBA_GROUP=dba \
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
DECLINE_SECURITY_UPDATES=true && \
rm -rf /opt/oracle/database
# Set environment variables
ENV ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
ENV PATH=$ORACLE_HOME/bin:$PATH
# Create Oracle database
RUN dbca -silent -createDatabase \
-templateName General_Purpose.dbc \
-gdbname orcl \
-sid orcl \
-sysPassword oracle \
-systemPassword oracle \
-createAsContainerDatabase false \
-numberOfPDBs 0 \
-databaseType OLTP \
-memoryMgmtType auto_sga \
-totalMemory 2048 \
-emConfiguration NONE
# Expose ports
EXPOSE 1521
EXPOSE 5500
# Start Oracle listener and database
CMD lsnrctl start && \
sqlplus /nolog @/opt/oracle/startup.sql && \
tail -f $ORACLE_BASE/diag/rdbms/*/ORCL/trace/alert*.log
```
启动命令:
```
docker run --name oracle -p 1521:1521 -p 5500:5500 -d <image_name>
```
其中,`<image_name>`是你构建的Oracle Docker镜像的名称。在运行容器时,将容器的1521端口映射到主机的1521端口,以便可以从主机访问Oracle数据库。同时,将容器的5500端口映射到主机的5500端口,以便可以从主机访问Oracle Enterprise Manager Express。
阅读全文