下载oracle11g安装包
https://www.oracle.com/database/technologies/oracle-database-software-downloads.html#11g
解压oracle11g安装包
使用uzip解压到安装目录/opt/oracle下面
sun@sun-system:/opt/oracle$ pwd
/opt/oracle
sun@sun-system:/opt/oracle$ ls
database
查找镜像
sun@sun-system:/opt/oracle$ sudo docker search oracle
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
oraclelinux Official Docker builds of Oracle Linux. 631 [OK]
jaspeen/oracle-11g Docker image for Oracle 11g database 148 [OK]
oracleinanutshell/oracle-xe-11g 83
oracle/openjdk Docker images containing OpenJDK Oracle Linux 60 [OK]
oracle/graalvm-ce GraalVM Community Edition Official Image 57 [OK]
获取镜像
sudo docker pull jaspeen/oracle-11g
sun@sun-system:/opt/oracle$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
jaspeen/oracle-11g latest 0c8711fe4f0f 4 years ago 281MB
sun@sun-system:/opt/oracle/database/install$ sudo docker run --privileged --name oracle11g -p 1521:1521 -v /opt/oracle:/install jaspeen/oracle-11g
Database is not installed. Installing...
Installing Oracle Database 11g
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 410593 MB Passed
Checking swap space: must be greater than 150 MB. Actual 8170 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2020-02-21_03-53-10AM. Please wait ...You can find the log of this install session at:
sudo docker run --privileged --name oracle11g -p 1521:1521 -v /opt/oracle:/install jaspeen/oracle-11g
- run 启动容器
- privileged 给这个容器root特权
- name 容器名称
- p 主机端口映射容器端口(主机1521端口映射容器1521端口)
- v 主机目录挂载到容器目录(主机/opt/oracle挂载到容器/install目录)
- jaspeen/oracle-11g 代表镜像jaspeen/oracle-11g的容器
等待一段时间安装完成
sun@sun-system:/opt/oracle$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
194bc8439080 jaspeen/oracle-11g "/assets/entrypoint.…" 31 minutes ago Up 31 minutes 0.0.0.0:1521->1521/tcp, 8080/tcp oracle11g
进入oracle11g容器
sun@sun-system:/opt/oracle$ sudo docker exec -it oracle11g /bin/bash
[root@194bc8439080 /]#
切换为oracle用户
[root@194bc8439080 /]# su - oracle
Last login: Fri Feb 21 04:00:47 UTC 2020
[oracle@194bc8439080 ~]$
登陆oracle数据库
[oracle@194bc8439080 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Fri Feb 21 04:25:59 2020
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
解锁演示用户scott
SQL> alter user scott account unlock;
User altered.
SQL> commit;
Commit complete.
SQL>
设置演示用户scott密码
SQL> conn scott/tiger
ERROR:
ORA-28001: the password has expired
Changing password for scott
New password:
Retype new password:
Password changed
Connected.
SQL>