Sign inSign up

haoxy/oracle

By haoxy

•Updated almost 7 years ago

通过oracle 官方提供的介质构建的oracle 19.3.0单实例镜像,官方脚本Dockerfile脚本稍有问题,进行了改动。

Image
1

485

haoxy/oracle repository overview

⁠1. 拉取镜像
docker pull haoxy/oracle:19.3.0-ee
⁠2. 启动镜像
  • 创建本地挂载点
#在本地(宿主机上)创建数据库挂载目录:
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.
⁠3. root用户登陆镜像
docker exec -u 0 -it --privileged ora19c /bin/bash

进入后可以修改root密码

⁠4. 重用持久化的文件
# 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
⁠5. 外部访问容器内的数据库

使用 本地的IP地址,映射的端口号,容器内Oracle SID进行连接。 例如:运行docker主机的IP: 192.168.2.135 映射的端口为:1521 SID: ORCL 外部连接:sqlplus system/[email protected]:1521/ORCL

Tag summary

Content type

Image

Digest

Size

2.7 GB

Last updated

almost 7 years ago

docker pull haoxy/oracle:19.3.0-ee