通过oracle 官方提供的介质构建的oracle 19.3.0单实例镜像,官方脚本Dockerfile脚本稍有问题,进行了改动。
485
docker pull haoxy/oracle:19.3.0-ee
#在本地(宿主机上)创建数据库挂载目录:
mkdir -p /oracle/oracle19c/data
docker run -d -it --name ora19c \
-p 1521:1521 \
-p 5500:5500 \
-e ORACLE_SID=orcl \
-e ORACLE_PWD=oracle \
-v /oracle/oracle19c/data:/opt/oracle/oradata haoxy/oracle:19.3.0-ee
-d 在后台运行
-it 提供一个交互界面
-v 容器的数据放在本地的/oracle/oracle19c/data下面,不会因为容器的删除而删除数据。相当于在容器的/opt/oracle/oradata挂载了本地的/oracle/oracle19c/data目录。
docker logs -f ora19c
出现下面提示,表示启动成功
#########################
DATABASE IS READY TO USE!
#########################
docker run --name <container name> \
-p <host port>:1521 -p <host port>:5500 \
-e ORACLE_SID=<your SID> \
-e ORACLE_PDB=<your PDB name> \
-e ORACLE_PWD=<your database passwords> \
-e ORACLE_CHARACTERSET=<your character set> \
-v [<host mount point>:]/opt/oracle/oradata \
oracle/database:19.3.0-ee
Parameters:
--name: The name of the container (default: auto generated)
-p: The port mapping of the host port to the container port.
Two ports are exposed: 1521 (Oracle Listener), 5500 (OEM Express)
-e ORACLE_SID: The Oracle Database SID that should be used (default: ORCLCDB)
-e ORACLE_PDB: The Oracle Database PDB name that should be used (default: ORCLPDB1)
-e ORACLE_PWD: The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated)
-e ORACLE_CHARACTERSET:
The character set to use when creating the database (default: AL32UTF8)
-v /opt/oracle/oradata
The data volume to use for the database.
Has to be writable by the Unix "oracle" (uid: 54321) user inside the container!
If omitted the database will not be persisted over container recreation.
-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.
docker exec -u 0 -it --privileged ora19c /bin/bash
进入后可以修改root密码
# 1. 停止现在的容器
[root@host01 oracle19c]# docker stop ora19c
ora19c
# 2. 删除容器
[root@host01 oracle19c]# docker rm ora19c
ora19c
[root@host01 oracle19c]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
# 3. 使用原来的SID,进行创建容器,新建的容器会直接重用持久化的数据文件启动数据库。
[root@host01 oracle19c]# docker run -d -it --name ora19c -p 1521:1521 -p 5500:5500 -e ORACLE_SID=orcl -e ORACLE_PWD=oracle -v /oracle/oracle19c/data:/opt/oracle/oradata haoxy/oracle:19.3.0-ee
使用 本地的IP地址,映射的端口号,容器内Oracle SID进行连接。 例如:运行docker主机的IP: 192.168.2.135 映射的端口为:1521 SID: ORCL 外部连接:sqlplus system/[email protected]:1521/ORCL
Content type
Image
Digest
Size
2.7 GB
Last updated
almost 7 years ago
docker pull haoxy/oracle:19.3.0-ee