ubuntu docker 安装 oracle
1、ubuntu 安装docker
sudo apt-get update
sudo apt-get docker.io
2、docker下载oracle镜像
sudo docker pull wnameless/oracle-xe-11g
下载完成后,查看镜像
sudo docker images
acer@acer-Aspire-TC-606:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
redis latest 55cb7014c24f 4 days ago 83.4 MB
rabbitmq 3-management f1c63d465125 6 days ago 149 MB
rabbitmq latest f3046c8947f1 6 days ago 125 MB
mongo latest 87f1a6e84e00 2 weeks ago 368 MB
wnameless/oracle-xe-11g latest 698cc7361de4 3 weeks ago 2.13 GB
rabbitmq <none> 6cb6e2f951a8 6 months ago 151 MB
rabbitmq <none> d53246bdedd1 6 months ago 127 MB
mongo <none> a0c8a8d1f8ec 6 months ago 366 MB
wnameless/oracle-xe-11g <none> f794779ccdb9 8 months ago 2.23 GB
cloudesire/activemq latest ae75f69be20a 16 months ago 305 MB
redis 2.8.21 fb83b0b93a51 2 years ago 109 MB
3、然后运行:docker run -d -p 9090:8080 -p 1521:1521 wnameless/oracle-xe-11g
出现了如图画框中的一串数字加字母的字符串,就说明运行成功此处的9090:8080是将容器中的oracleXE管理界面的8080端口映射位本机的9090端口,
1521:1521是将oracleXE的1521端口映射位本机的1521端口
acer@acer-Aspire-TC-606:~$ sudo docker run -d -p 7070:8080 -p 1521:1521 wnameless/oracle-xe-11g
8bab1c2387456c1548abc00886fe710c24d0993fc9fb5a0186fba9a19307406a
4、docker ps -a
查看容器,发现了oracle已在里面了
acer@acer-Aspire-TC-606:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8bab1c238745 wnameless/oracle-xe-11g "/bin/sh -c '/usr/..." 2 minutes ago Up 2 minutes 22/tcp, 0.0.0.0:1521->1521/tcp, 0.0.0.0:7070->8080/tcp wonderful_thompson
0679732e03fe wnameless/oracle-xe-11g "/bin/sh -c '/usr/..." 48 minutes ago Created laughing_colden
c699e28b73f8 wnameless/oracle-xe-11g "/bin/sh -c '/usr/..." About an hour ago Created
5、启动容器 docker start container id
acer@acer-Aspire-TC-606:~$ sudo docker start 8bab1c238745
8bab1c238745
6、进入容器 sudo docker exec -ti 8bab1c238745 bash
这个container id还是上图中的那个ID
acer@acer-Aspire-TC-606:~$ sudo docker exec -ti 8bab1c238745 bash
root@8bab1c238745:/#
7、查看进程ps ax
root@8bab1c238745:/# ps -ax
PID TTY STAT TIME COMMAND
1 ? Ss 0:00 /bin/sh -c /usr/sbin/startup.sh && tail -f /dev/null
26 ? Ssl 0:00 /u01/app/oracle/product/11.2.0/xe/bin/tnslsnr LISTENER -inherit
40 ? Ss 0:00 xe_pmon_XE
42 ? Ss 0:00 xe_psp0_XE
44 ? Ss 0:00 xe_vktm_XE
48 ? Ss 0:00 xe_gen0_XE
50 ? Ss 0:00 xe_diag_XE
52 ? Ss 0:00 xe_dbrm_XE
54 ? Ss 0:00 xe_dia0_XE
56 ? Ss 0:00 xe_mman_XE
58 ? Ss 0:00 xe_dbw0_XE
60 ? Ss 0:00 xe_lgwr_XE
62 ? Ss 0:00 xe_ckpt_XE
64 ? Ss 0:00 xe_smon_XE
66 ? Ss 0:00 xe_reco_XE
68 ? Ss 0:00 xe_mmon_XE
70 ? Ss 0:00 xe_mmnl_XE
72 ? Ss 0:00 xe_d000_XE
74 ? Ss 0:00 xe_s000_XE
76 ? Ss 0:00 xe_s001_XE
78 ? Ss 0:00 xe_s002_XE
80 ? Ss 0:00 xe_s003_XE
88 ? Ss 0:01 xe_vkrm_XE
90 ? Ss 0:00 xe_qmnc_XE
92 ? S 0:00 tail -f /dev/null
106 ? Ss 0:00 xe_cjq0_XE
116 ? Ss 0:00 xe_q000_XE
118 ? Ss 0:00 xe_q001_XE
128 ? Ss 0:00 xe_smco_XE
130 ? Ss 0:00 xe_w000_XE
135 ? Ss 0:00 bash
144 ? R+ 0:00 ps -ax
8、配置环境变量
find -name oracle 可以找到安装的oracle位置
root@8bab1c238745:/# find -name oracle
./u01/app/oracle
./u01/app/oracle/product/11.2.0/xe/bin/oracle
find: './proc/26/map_files': Permission denied
find: './proc/40/map_files': Permission denied
find: './proc/42/map_files': Permission denied
find: './proc/44/map_files': Permission denied
find: './proc/48/map_files': Permission denied
find: './proc/50/map_files': Permission denied
find: './proc/52/map_files': Permission denied
find: './proc/54/map_files': Permission denied
find: './proc/56/map_files': Permission denied
find: './proc/58/map_files': Permission denied
find: './proc/60/map_files': Permission denied
find: './proc/62/map_files': Permission denied
find: './proc/64/map_files': Permission denied
find: './proc/66/map_files': Permission denied
find: './proc/68/map_files': Permission denied
find: './proc/70/map_files': Permission denied
find: './proc/72/map_files': Permission denied
find: './proc/74/map_files': Permission denied
find: './proc/76/map_files': Permission denied
find: './proc/78/map_files': Permission denied
find: './proc/80/map_files': Permission denied
find: './proc/88/map_files': Permission denied
find: './proc/90/map_files': Permission denied
find: './proc/106/map_files': Permission denied
find: './proc/116/map_files': Permission denied
find: './proc/118/map_files': Permission denied
find: './proc/128/map_files': Permission denied
find: './proc/130/map_files': Permission denied
export ORACLE_HOME=./u01/app/oracle/product/11.2.0/xe/bin/oracle 设置oracle_home(记得路径是在/bin之前的)
export ORACLE_SID=XE 设置SID
export PATH=$PATH:$ORACLE_HOME/bin 设置path
root@8bab1c238745:/# export ORACLE_HOME=./u01/app/oracle/product/11.2.0/xe/bin/oracle
root@8bab1c238745:/# export ORACLE_SID=XE
root@8bab1c238745:/# export PATH=$PATH:$ORACLE_HOME/bin
9、进入oracle:su – oracle (进入成功的话#会变成$如图所示)
root@8bab1c238745:/# su - oracle
oracle@8bab1c238745:~$
10、以操作系统权限认证的oracle sys管理员登陆:sqlplus / as sysdba
oracle@8bab1c238745:~$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Mon Jun 25 08:14:00 2018
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL>
11、docker 删除容器
sudo docker ps -a
acer@acer-Aspire-TC-606:~$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8bab1c238745 wnameless/oracle-xe-11g "/bin/sh -c '/usr/..." 19 minutes ago Up 19 minutes 22/tcp, 0.0.0.0:1521->1521/tcp, 0.0.0.0:7070->8080/tcp wonderful_thompson
0679732e03fe wnameless/oracle-xe-11g "/bin/sh -c '/usr/..." About an hour ago Created laughing_colden
c699e28b73f8 wnameless/oracle-xe-11g "/bin/sh -c '/usr/..." About an hour ago Created
sudo docker rm CONTAINER ID
本文章参考 https://www.cnblogs.com/Jin520304/p/7884441.html