The procedure is as follows.
--Create a container image --Compatible with Windows / Linux version --Moderate setup with docker-compose etc.
--People who want to launch an oracle instance including data on docker
The code etc. described in this document is WTFPL2 license [^ 2] except for those derived from other reference materials [^ 1], and any guarantee There is no. [^ 1]: The ones derived from the reference materials are related to vagrant related code and docker build related [^ 2]: From Wikipedia: Do whatever you want, shit, public license (contract) The error handling is loose, so please improve it.
In any folder (tools) [oracle-xe-11.2.0-1.0.x86_64.rpm.zip](http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index. html) (Oracle Database 11g Release 2 Express Edition for Linux x64) is downloaded. Place the following batch in any folder (tools).
get_oracle.bat(For windows)
set WORKING_DIR=%TMP%\oracle_build_wk
set CURRENT_DIR=%CD%
echo %WORKING_DIR%
mkdir %WORKING_DIR%
copy oracle-xe-11.2.0-1.0.x86_64.rpm.zip %WORKING_DIR%\
cd %WORKING_DIR%
curl --output Dockerfile.xe -sSL --url https://github.com/oracle/docker-images/raw/master/OracleDatabase/SingleInstance/dockerfiles/11.2.0.2/Dockerfile.xe
curl --output checkDBStatus.sh -sSL --url https://github.com/oracle/docker-images/raw/master/OracleDatabase/SingleInstance/dockerfiles/11.2.0.2/checkDBStatus.sh
curl --output runOracle.sh -sSL --url https://github.com/oracle/docker-images/raw/master/OracleDatabase/SingleInstance/dockerfiles/11.2.0.2/runOracle.sh
curl --output setPassword.sh -sSL --url https://github.com/oracle/docker-images/raw/master/OracleDatabase/SingleInstance/dockerfiles/11.2.0.2/setPassword.sh
curl --output xe.rsp -sSL --url https://github.com/oracle/docker-images/raw/master/OracleDatabase/SingleInstance/dockerfiles/11.2.0.2/xe.rsp
docker build %WORKING_DIR% --force-rm=true --no-cache=true --shm-size=1G --build-arg DB_EDITION=xe -t oracle/database:11.2.0.2-xe -f Dockerfile.xe > %CURRENT_DIR%\oracle11g_build.log 2>&1
cd %CURRENT_DIR%
del /Q /S %WORKING_DIR%
echo DONE
get_oracle.sh(For Linux)
#!/bin/sh
WORKDIR=/tmp/oracle11
CURRENTDIR=$(pwd)
mkdir $WORKDIR
cp oracle-xe-11.2.0-1.0.x86_64.rpm.zip $WORKDIR/
cd $WORKDIR
curl --output Dockerfile.xe -sSL --url https://github.com/oracle/docker-images/raw/master/OracleDatabase/SingleInstance/dockerfiles/11.2.0.2/Dockerfile.xe
curl --output checkDBStatus.sh -sSL --url https://github.com/oracle/docker-images/raw/master/OracleDatabase/SingleInstance/dockerfiles/11.2.0.2/checkDBStatus.sh
curl --output runOracle.sh -sSL --url https://github.com/oracle/docker-images/raw/master/OracleDatabase/SingleInstance/dockerfiles/11.2.0.2/runOracle.sh
curl --output setPassword.sh -sSL --url https://github.com/oracle/docker-images/raw/master/OracleDatabase/SingleInstance/dockerfiles/11.2.0.2/setPassword.sh
curl --output xe.rsp -sSL --url https://github.com/oracle/docker-images/raw/master/OracleDatabase/SingleInstance/dockerfiles/11.2.0.2/xe.rsp
DOCKEROPS=""
VERSION=11.2.0.2
EDITION="xe"
DOCKERFILE="Dockerfile"
DOCKEROPS="--shm-size=1G $DOCKEROPS";
IMAGE_NAME="oracle/database:$VERSION-$EDITION"
DOCKERFILE="$DOCKERFILE.$EDITION"
docker build ./ --force-rm=true --no-cache=true \
$DOCKEROPS --build-arg DB_EDITION=$EDITION \
-t $IMAGE_NAME -f $DOCKERFILE
cd $CURRENTDIR
rm -rf $WORKDIR
echo DONE
Execute get_oracle.bat
or get_oracle.sh
.
chmod + x get_oracle.sh
)
If you proceed without error, you will have oracle / database 11.2.0.2-xe
.If it is left as it is, it will not taste good at all, so I will post the recipe. (Since it is not persistent, the data will be reset if you recreate the container)
docker-compose.yml
version: '3'
services:
##Describe other services as needed
oracledb_test:
image: oracle/database:11.2.0.2-xe
ports:
- "1521:1521"
#- "8080:8080"
volumes:
#The script here runs with dba privileges. If you want to use sqlplus, imp, etc., place the sh file
#Since it is read-only, be careful when outputting a log file.
- ./oracledb/setup:/u01/app/oracle/scripts/setup:ro
#Conte later
- ./oracledb/mnt:/mnt/local
shm_size: 1g
environment:
- NLS_LANG=Japanese_Japan.UTF8
- TZ=Asia/Tokyo
oracledb\setup\00_user_create.sql(UTF-8)
--You will be given a password without permission, so change it.(Please specify an absolutely different password)
ALTER USER sys IDENTIFIED BY manager;
ALTER USER system IDENTIFIED BY manager;
--User created
CREATE USER test_user IDENTIFIED BY test_user DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp QUOTA UNLIMITED ON users;
--Role creation
create role conn_testuser;
GRANT CREATE session, CREATE sequence, CREATE trigger, CREATE table, CREATE view, CREATE procedure, CREATE synonym TO conn_scn;
--Authorization
GRANT conn_testuser TO test_user;
--It closes without permission, so you don't need to exit.
When inputting data with sql, create the following file.
oracledb\setup\01_ddl.sql(UTF-8)
--Switch schema
ALTER SESSION SET CURRENT_SCHEMA = test_user;
--Table creation, etc.
--It closes without permission, so you don't need to exit.
If you want to set up an Oracle instance on Vagrant, you can create an image by writing as follows. Make sure the virtual machine instance memory is at least 2G. (Otherwise you will not be able to start oracle)
Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
#Omission
#if Vagrant.has_plugin?("vagrant-cachier")
# config.cache.scope = :box
#end
#Omission
config.vm.provision "docker", run: "always"
#from here
# Setup docker image for oracle 11g XE environment
config.vm.synced_folder "./tools", "/tmp/tools", create: true
config.vm.provision "shell", inline: <<-SHELL
cd /tmp/tools
/bin/sh ./get_oracle.sh
SHELL
#So far
config.vm.provision "docker_compose",
compose_version: "1.24.1",
yml: "/vagrant/docker/docker-compose.yml",
run: "always"
end