第一步:下载镜像
docker pull filemon/oracle_11g
备注:docker images -a 可以查看已安装镜像;
第二步:启动镜像
docker run -d -p 11521:1521 -p 10022:22 --name=oracle11g filemon/oracle_11g
参数解释:
1.-p 11521:1521允许远程的客户端可以从11521端口连接到数据库实例(端口映射,格式为:主机(宿主)端口:容器端口).
2.-d: 后台运行容器,并返回容器ID;
3.--name="oracle11g": 为容器指定一个名称;
备注:
实例名(SID ) | orcl |
管理员帐号 | system |
管理员密码 | admin |
字符集 | utf-8 |
第三步:用root用户进入镜像
docker exec -it --user root oracle11g /bin/bash
备注:
1.docker exec :在运行的容器中执行命令
2.-t :分配一个伪终端
3.oracle11g 是容器的名称
第四步:创建表空间
1.先执行docker exec -it --user root oracle11g /bin/bash
2.创建/oracle/product目录,并执行chmod 777 /oracle/product(给文件夹赋权限)
以下是创建表空间的脚本
--data store
create tablespace POIN
datafile '/oracle/product/POIN.dbf'
size 100m
autoextend on next 50m;
--index store
create tablespace POIN_INDEX
datafile '/oracle/product/POIN_INDEX.dbf'
size 100m
autoextend on next 50m;
-- Create the user
create user poin
identified by poin
default tablespace POIN
temporary tablespace TEMP
profile DEFAULT;
-- Grant/Revoke role privileges
grant connect to poin;
grant dba to poin;
grant resource to poin;
-- Grant/Revoke system privileges
grant unlimited tablespace to poin;
--end create_tablespace_user.sql