1.拉取镜像
docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
2.创建并运行容器
docker run -d -p 1521:1521 --name oracle_11g --restart=always registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
-d 后台运行容器,并返回容器Id
-p 1521:1521 将主机1521端口映射到容器1521端口
–name oracle_11g 设置容器别名
–restart=always 在重启docker时,自动启动相关容器
3.启动服务
docker start oracle_11g
4.配置oracle
4.1虚拟控制台–切换root用户–输入密码helowin
docker exec -it oracle_11g bash
su root
helowin
4.2 编辑环境变量 vi /etc/profile 在文件的末尾添加一下内容
export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH
使修改后的文件生效
source /etc/profile
exit
exit
进入控制台,修改密码,创建用户授权
docker ps
docker exec -it f902b5482611 /bin/bash
source ~/.bash_profile
sqlplus /nolog
conn as sysdba
alter user system identified by system;
alter user sys identified by sys;
create user ETS identified by ETS;
grant connect,resource,dba to ETS ;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
exit ##退出编辑SQL