1. 程式人生 > 其它 >Docker-安裝使用Oracle 11g

Docker-安裝使用Oracle 11g

1、安裝Docker

2、Docker倉庫搜尋Oracle 11g映象

look@lookdeMacBook-Pro ~ % docker search docker-oracle-xe-11g
NAME                                 DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
deepdiver/docker-oracle-xe-11g                                                       41
[OK] epiclabs/docker-oracle-xe-11g Customized Oracle XE 11g build for CI and de… 22 [OK] pengbai/docker-oracle-xe-11g-r2 oracle xe 11g r2 with sql initdb and web con… 10 [OK] arahman/docker-oracle-xe-11g phusion/baseimage based spin off of alexei-l… 9
[OK] konnecteam/docker-oracle-xe-11g Fork of https://github.com/wnameless/docker-… 4 [OK] rafaelri/docker-oracle-xe-11g Fork from wnameless/docker-oracle-xe-11g 3 [OK] ignatov/docker-oracle-xe-11g Dockerfile of Oracle Database Express Editio… 3
[OK] gswteam/docker-oracle-xe-11g Oracle XE 11g 0 [OK] nguoianphu/docker-oracle-xe-11g Oracle Express Edition 11g Release 2 on Ubun… 0 [OK] jeromefromcn/docker-oracle-xe-11g docker-oracle-xe-11g 0 [OK] zzzfree/docker-oracle-xe-11g docker-oracle-xe-11g 0 [OK] lynxsolutions/docker-oracle-xe-11g docker-oracle-xe-11g 0 [OK] deadok22/docker-oracle-xe-11g docker-oracle-xe-11g 0 dbanttari/docker-oracle-xe-11g Branch of wnameless/docker-oracle-xe-11g tha… 0 [OK] rdehuyss/docker-oracle-xe-11g Oracle Express 11g R2 on Ubuntu 14.04.2 LTS 0 [OK] xtechnologies/docker-oracle-xe-11g docker-oracle-xe-11g 0 [OK] bizybot/docker-oracle-xe-11g wnameless/docker-oracle-xe-11g 0 [OK] cheyu0325/docker-oracle-xe-11g docker-oracle-xe-11g 0 kikicarbonell/docker-oracle-xe-11g Docker image of Oracle Database Express Edit… 0 [OK] zigac/docker-oracle-xe-11g Oracle xe 11g 0 [OK] ceagan/docker-oracle-xe-11g Modified version of wnameless/docker-oracle-… 0 [OK] dockerbolcom/docker-oracle-xe-11g Fork of https://github.com/wnameless/docker-… 0 [OK] demers/docker-oracle-xe-11g-spark Oracle XE 11g with Spark 0 gmartsenkov/docker-oracle-xe-11g oracle 0 [OK] demers/docker-oracle-xe-11g Docker Oracle 11g XE with Java 13 and Python… 0

3、選擇一個想要的Oracle 11g版本拉取下來

docker pull deepdiver/docker-oracle-xe-11g

4、啟動映象

docker run -h "oracle" --name "oracle" -d -p 49160:22 -p 49161:1521 -p 49162:8080 deepdiver/docker-oracle-xe-11g

5、檢視容器id並進入容器

look@lookdeMacBook-Pro ~ % docker ps -al
CONTAINER ID   IMAGE                            COMMAND                  CREATED         STATUS         PORTS                                                                     NAMES
35fd8ae5ce60   deepdiver/docker-oracle-xe-11g   "/bin/sh -c 'sed -i …"   2 minutes ago   Up 2 minutes   0.0.0.0:49160->22/tcp, 0.0.0.0:49161->1521/tcp, 0.0.0.0:49162->8080/tcp   oracle
look@lookdeMacBook-Pro ~ % docker exec -it 35fd8ae5ce60 /bin/bash

6、通過sqlplu連線資料庫。oracle的高階使用者有兩個 sys和system。在我pull的這個docker oracle 11g 的版本,密碼都是oracle

#用system使用者登入資料庫
sqlplus system/oracle

7、建立一個使用者並分配許可權

-- 檢視使用者
select username,password from dba_users;

-- 建立使用者
create user deque identified by 123;

-- 給新使用者授權
grant connect,resource to deque;

8、用Navicat 連線 docker oracle 11g

8.1 檢視oracle 的對映埠。 0.0.0.0:49161-->1521

8.2 進入容器中檢視oracle 的service_name

-- 檢視容器ID
docker ps -l

CONTAINER ID   IMAGE                            COMMAND                  CREATED       STATUS       PORTS                                                                     NAMES
35fd8ae5ce60   deepdiver/docker-oracle-xe-11g   "/bin/sh -c 'sed -i …"   4 hours ago   Up 4 hours   0.0.0.0:49160->22/tcp, 0.0.0.0:49161->1521/tcp, 0.0.0.0:49162->8080/tcp   oracle

-- 進入容器
docker exec -it 35fd8ae5ce60 /bin/bash

-- sqlplus 登入 system使用者
sqlplus system/oracle

-- 檢視服務名
show parameter service

9、其他:

-- 停止docker oracle服務
docker stop oracle

-- 啟動docker oracle 服務
docker start oracle

參考:

  https://www.jianshu.com/p/b867263995b5