Fork me on GitHub
Suzf  Blog

How-to run Oracle 12.2 with docker on Ubuntu

License: Attribution-NonCommercial-ShareAlike 4.0 International

本文出自 Suzf Blog。 如未注明,均为 SUZF.NET 原创。



昨天有一位搞 DBA 同学问我会不会用 Docker。Ta 想要在上面跑一个 Oracle 实例。整个过程非常流畅,写篇文章备用。 :)

# lsb_release -a
Distributor ID: Ubuntu
Description:  Ubuntu 16.04.2 LTS
Release:  16.04
Codename: xenial
# Oracle Version Package

Install docker

sudo apt-key adv --keyserver hkp:// --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
apt-get update
apt-get install docker-engine -y
Download Oracle Docker Image

Docker Images from Oracle

cd ~
git clone [email protected]:oracle/docker-images.git  oracle-images
Download & Upload Oracle

Download page

when you download the package, upload it to the ${docker-images}/OracleDatabase/dockerfiles/x.x.x.x/

du -sh ./oracle-images/OracleDatabase/dockerfiles/* | grep zip
3.3G    ./oracle-images/OracleDatabase/dockerfiles/

接下来,开始无脑安装。因为有一些依赖包需要安装,请确保 REPO & 网络可用。

Build Docker Image

# bash oracle-images/OracleDatabase/dockerfiles/ -v -e
# bash oracle-images/OracleDatabase/dockerfiles/
Usage: -v [version] [-e | -s | -x] [-i]
Builds a Docker Image for Oracle Database.
   -v: version to build
       Choose one of: oracle-images  
   -e: creates image based on 'Enterprise Edition'
   -s: creates image based on 'Standard Edition 2'
   -x: creates image based on 'Express Edition'
   -i: ignores the MD5 checksums
* select one edition only: -e, -s, or -x
Copyright (c) 2014-2017 Oracle and/or its affiliates. All rights reserved.


Oracle Database Docker Image for 'ee' version is ready to be extended:
--> oracle/database:
build completed in 50235 second

Check Image

$sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
oracle/database         2b8746d2b5a0        23 hours ago        14.8GB
oraclelinux         7-slim              0b44f4e6980d        13 days ago         114MB

Run Oracle

docker run --name oracle
-p 1521:1521
-p 5500:5500
-v /opt/oracle/oradata:/opt/oracle/oradata
docker run --name <container name> \
-p <host port>:1521 -p <host port>:5500 \
-e ORACLE_SID=<your SID> \
-e ORACLE_PDB=<your PDB name> \
-e ORACLE_PWD=<your database passwords> \
-e ORACLE_CHARACTERSET=<your character set> \
-v [<host mount point>:]/opt/oracle/oradata \
   --name:        The name of the container (default: auto generated)
   -p:            The port mapping of the host port to the container port.
                  Two ports are exposed: 1521 (Oracle Listener), 5500 (OEM Express)
   -e ORACLE_SID: The Oracle Database SID that should be used (default: ORCLCDB)
   -e ORACLE_PDB: The Oracle Database PDB name that should be used (default: ORCLPDB1)
   -e ORACLE_PWD: The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated)
                  The character set to use when creating the database (default: AL32UTF8)
   -v             The data volume to use for the database.
                  Has to be owned by the Unix user "oracle" or set appropriately.
                  If omitted the database will not be persisted over container recreation.
Changing the admin accounts passwords

# ./OracleDatabase/dockerfiles/
docker exec <container name> ./ <your password>

更多信息 详见

$sudo docker ps
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS                                            NAMES
aba4fc65f3e7        oracle/database:   "/bin/sh -c 'exec ..."   7 hours ago         Up 2 hours>1521/tcp,>5500/tcp   oracle

Oracle SQL Developer Test

至此,一个基于 Docker 的简单测试环境构建完成。

~ EOF ~




「一键投喂 软糖/蛋糕/布丁/牛奶/冰阔乐!」

Suzf Blog

(๑>ڡ<)☆ 谢谢 ~