docker run -d --name test --restart unless-stopped \
-p 1521:1521 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
mkdir -p /var/oracle11/data
docker cp test:/home/oracle/app/oracle/oradata/helowin /var/oracle11/data
cd /var/oracle11/data
chown -R 500.500 helowin # 500 500 是容器内 oracle 组和用户的 id
启动容器
docker rm -f test
docker run -d --name oracle11g --restart unless-stopped \
-v /var/oracle11/data/helowin:/home/oracle/app/oracle/oradata/helowin \
-p 1521:1521 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
初始化数据库
docker exec -it oracle11g bash
su - oracle #密码为helowin
cd /home/oracle/
source .bash_profile
sqlplus / as sysdba # 连接 oracle 数据库
alter user system identified by oracle; # 修改 DBA 账号的密码
alter user sys identified by oracle; # 修改 DBA 账号的密码
alter profile default limit password_life_time unlimited; # 设置密码为永不过期
create user test identified by oracle; # 创建一个 test 用户,密码 oracle
select * from dba_users t where t.username = 'TEST'; # 查询用户是否创建成功
grant connect, resource to test; # 给用户授予连接和数据权限