Docker 大大简化了数据库的安装,特别是在产品测试阶段的时候,可以让开发者以最快速的方式体验技术产品,尤其是当这个技术产品已经非常复杂的时候。
Oracle 官方提供了哪些镜像
Oracle 镜像官方页面
Oracle 在官方站点中列出了所有支持的产品,以及对应的仓库列表。 Oracle 镜像仓库的官方页面:
仓库官方页: https://container-registry.oracle.com/

找到软件对应的子仓库
这里关注 Oracle Database 相关的仓库,故选择第一个仓库列表页。在这里可以看到有很多的子仓库,可以用于安装不同的 Oracle 数据库版本或组件:

选择版本与镜像站点
进入单个子仓库,在页面的最底下可以看到,该仓库有哪些版本的镜像可以使用,例如,这里选择了 express
子仓库,在页面最底端找到支持的版本列表:

另外,这里还提供了一些可供选择的镜像列表,开发者可以根据自己的地理位置选择合适的镜像站点。
安装 Oracle 数据库
拉取镜像
docker pull container-registry.oracle.com/database/express:latest
or:
docker pull container-registry.oracle.com/database/express:21.3.0-xe
or:
docker pull container-registry.oracle.com/database/express:18.4.0-xe
这里的测试选择了express:18.4.0-xe
版本进行安装。查看本地的镜像:
docker image ls
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
REPOSITORY TAG IMAGE ID CREATED SIZE
container-registry.oracle.com/mysql/community-server 9.1 f1f889678a73 6 months ago 606 MB
container-registry.oracle.com/database/express 18.4.0-xe 364598d20118 4 years ago 6.03 GB
创建 Oracle 数据库的容器
docker container create \
-it \
--name oracle-18ex \
-p 1521:1521 \
-e ORACLE_PWD=oracledocker \
container-registry.oracle.com/database/express:18.4.0-xe
启动容器
docker start oracle-18ex
观察启动状态
docker logs -f oracle-18ex
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
ORACLE PASSWORD FOR SYS AND SYSTEM: oracledocker
Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts:
Confirm the password:
Configuring Oracle Listener.
Listener configuration succeeded.
Configuring Oracle Database XE.
Enter SYS user password:
****************
Enter SYSTEM user password:
*************
Enter PDBADMIN User Password:
*************
Prepare for db operation
7% complete
Copying database files
29% complete
Creating and starting Oracle instance
30% complete
31% complete
34% complete
38% complete
41% complete
43% complete
Completing Database Creation
47% complete
50% complete
Creating Pluggable Databases
54% complete
71% complete
Executing Post Configuration Actions
93% complete
Running Custom Scripts
100% complete
Database creation complete. For details check the logfiles at:
/opt/oracle/cfgtoollogs/dbca/XE.
Database Information:
Global Database Name:XE
System Identifier(SID):XE
Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE.log" for further details.
Connect to Oracle Database using one of the connect strings:
Pluggable database: bd127ae4faab/XEPDB1
Multitenant container database: bd127ae4faab
Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE
The Oracle base remains unchanged with value /opt/oracle
#########################
DATABASE IS READY TO USE!
#########################
The following output is now a tail of the alert.log:
2025-04-17T03:40:43.663079+00:00
XEPDB1(3):Resize operation completed for file# 10, old size 358400K, new size 368640K
2025-04-17T03:40:44.483587+00:00
XEPDB1(3):CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/opt/oracle/oradata/XE/XEPDB1/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
XEPDB1(3):Completed: CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/opt/oracle/oradata/XE/XEPDB1/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
XEPDB1(3):ALTER DATABASE DEFAULT TABLESPACE "USERS"
XEPDB1(3):Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS"
2025-04-17T03:40:44.930766+00:00
ALTER PLUGGABLE DATABASE XEPDB1 SAVE STATE
Completed: ALTER PLUGGABLE DATABASE XEPDB1 SAVE STATE
登录容器中的 Oracle 数据库
在上面的输出中可以看到,安装时会默认创建如下数据库:
Database Information:
Global Database Name:XE
System Identifier(SID):XE
根据在上述 docker
命令中指定的密码,则可以使用如下的命令登录数据数据库:
docker exec -it oracle-18ex sqlplus sys/oracledocker@XE as sysdba
or:
docker exec -it oracle-18ex sqlplus system/oracledocker@XE
登录后,会有如下提示输入:
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
SQL*Plus: Release 18.0.0.0.0 - Production on Thu Apr 17 03:56:27 2025
Version 18.4.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Last Successful login time: Thu Apr 17 2025 03:49:37 +00:00
Connected to:
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0
SQL>
授权协议与认证
如果你要使用 Oracle 数据库的企业版的话,在拉取镜像前则需要先登录官网“同意”相关的协议,并使用docker login
的方式进行认证,然后才可以拉取镜像。
requested access to the resource is denied
如果没有认证或提前在官网统一协议,则可能遇到如下报错:requested access to the resource is denied
:
docker pull container-registry.oracle.com/database/enterprise:12.2.0.1
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Trying to pull container-registry.oracle.com/database/enterprise:12.2.0.1...
Error: initializing source docker://container-registry.oracle.com/database/enterprise:12.2.0.1: reading manifest 12.2.0.1 in container-registry.oracle.com/database/enterprise: requested access to the resource is denied
或者:invalid username/password: authentication required
docker pull container-registry-tokyo.oracle.com/database/enterprise:12.2.0.1
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Trying to pull container-registry-tokyo.oracle.com/database/enterprise:12.2.0.1...
Error: initializing source docker://container-registry-tokyo.oracle.com/database/enterprise:12.2.0.1: unable to retrieve auth token: invalid username/password: authentication required
解决上述问题,首先需要登录Oracle镜像的官方站点,并同意相关协议,然后使用docker login
完成认证,后即可下载。
登录Oracle仓库站点并同意协议
例如,如果需要下载“Oracle Database Enterprise Edition”,则需要先进入对应仓库站点:链接,并在页面的右侧栏点击协议并同意协议:

docker login
同意协议后,就可以使用docker login
登录账号并进行镜像的下载了。
Enterprise Edition的Docker安装
在参考 Oracle 企业版官方文档(参考)进行安装部署的时候,在 AlmaLinux 部署时会遇到如下的问题:
docker exec -it oracle-1202ee sqlplus / as sysdba
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Error: crun: executable file `sqlplus` not found in $PATH: No such file or directory: OCI runtime attempted to invoke a command that was not found
当前的绕过方案是,进入容器的bash
,然后再执行即可:
[root@oracle-docker-test ~]# docker exec -it oracle-1202ee bash
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
[oracle@8bb1ec09ec5e /]$ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Fri Apr 18 02:37:30 2025
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL>
创建容器时的参数
在创建容器的时候,可以使用命令行进行部分启动参数的配置。例如,默认启动时,是没有开启归档日志的(Archive Logs)的,则可以通过添加如下容器构建参数:
-e ENABLE_ARCHIVELOG=true
完整的命令:
docker container create \
-it \
--name oracle-1202ee \
-p 1521:1521 \
-e ENABLE_ARCHIVELOG=true \
-e ORACLE_PWD=oracledocker \
container-registry.oracle.com/database/enterprise:12.2.0.1
相关资源
- Oracle 镜像仓库官方站点:Oracle Container Registry
- Oracle 官方 GitHub 镜像列表:docker-images/OracleDatabase@GitHub
- Oracle 官方容器镜像使用说明:
Leave a Reply