Oracle
在 Windows 10 Pro 中建構 Oracle XE docker 映像
我正在嘗試在 Windows 10 的 docker 容器中安裝 Oracle XE 18c。我已經安裝了 docker,我需要按照此處的說明建構映像。
我複製了 git 儲存庫,但我被困在這一步,因為我複製的是 Linux 命令而不是 Windows。
複製後:
git clone https://github.com/oracle/docker-images.git
如果我
cd
要docker-images\OracleDatabase\SingleInstance\dockerfiles\18.4.0
建構圖像,我會看到以下sh
命令,而不是exe
orbat
:12/28/2019 01:36 PM 1,137 checkDBStatus.sh 12/28/2019 01:36 PM 905 checkSpace.sh 12/28/2019 01:36 PM 75 Checksum.xe 12/28/2019 01:36 PM 2,752 Dockerfile.xe 12/28/2019 01:36 PM 533 oracle-xe-18c.conf 12/28/2019 01:36 PM 6,132 runOracle.sh 12/28/2019 01:36 PM 775 setPassword.sh
如何在 Windows 中建構此映像?
使用 Wsl Ubuntu Bash 設置 Docker 執行檔的路徑,或者簡單地從 Docker Tools 安裝 Git Bash for Windows 並從 Git Bash 終端執行 shell 腳本(我更喜歡 Git Bash)。下載並複制 Oracle18xe rpm 文件到 18.40 文件夾
這是 Windows 的 Git Bash 的輸出
xxx@localhost MINGW64 /d/docker-images/OracleDatabase/SingleInstance/dockerfiles/18.4.0 (master) $ ls -lrt total 2513906 -rw-r--r-- 1 user 197121 74 Dec 28 13:17 Checksum.xe -rw-r--r-- 1 user 197121 2675 Dec 28 13:17 Dockerfile.xe -rwxr-xr-x 1 user 197121 1137 Dec 28 13:17 checkDBStatus.sh* -rwxr-xr-x 1 user 197121 905 Dec 28 13:17 checkSpace.sh* -rw-r--r-- 1 user 197121 533 Dec 28 13:17 oracle-xe-18c.conf -rwxr-xr-x 1 user 197121 6132 Dec 28 13:17 runOracle.sh* -rwxr-xr-x 1 user 197121 775 Dec 28 13:17 setPassword.sh* -rw-r--r-- 1 user 197121 2574155124 Dec 28 13:48 oracle-database-xe-18c-1.0-1.x86_64.rpm
成功執行shell腳本後
xxx@localhost MINGW64 /d/docker-images/OracleDatabase/SingleInstance/dockerfiles/18.4.0 (master) $ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE oracle/database 18.4.0-xe 19b38be42ae6 30 minutes ago 8.44GB oraclelinux 7-slim 0d49b70bc432 9 days ago 118MB xxx@localhost MINGW64 /d/docker-images/OracleDatabase/SingleInstance/dockerfiles (master) $ docker run --name myxedb \ > -d \ > -p 51521:1521 \ > -p 55500:5500 \ > -e ORACLE_PWD=xxxxxxx \ > -e ORACLE_CHARACTERSET=AL32UTF8 \ > oracle/database:18.4.0-xe xxx@localhost MINGW64 /d/docker-images/OracleDatabase/SingleInstance/dockerfiles/18.4.0 (master) $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES afce013adb98 oracle/database:18.4.0-xe "/bin/sh -c 'exec $O…" 19 seconds ago Up 16 seconds (health: starting) 8080/tcp, 0.0.0.0:51521->1521/tcp, 0.0.0.0:55500->5500/tcp myxedb
您可以通過 sqlplus 連接到數據庫或使用 Windows Dos 登錄到 docker 容器
D:\>docker exec -it --user=oracle myxedb bash [oracle@afce013adb98 /]$ . oraenv ORACLE_SID = [XE] ? The Oracle base remains unchanged with value /opt/oracle [oracle@afce013adb98 /]$ sqlplus / as sysdba SQL*Plus: Release 18.0.0.0.0 - Production on Sun Dec 29 05:04:32 2019 Version 18.4.0.0.0 Copyright (c) 1982, 2018, Oracle. All rights reserved. Connected to: Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production Version 18.4.0.0.0 SQL> select banner from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
PS:-確保您從 git bash 終端登錄到 docker hub
docker login
要使用 WSL 子系統 bash 終端,請將路徑和別名添加到 .bashrc
export PATH="$HOME/bin:$HOME/.local/bin:/mnt/c/Program\Files/Docker/Docker/resources/bin:$PATH" alias docker=docker.exe alias docker-compose=docker-compose.exe
從 WSL Bash 終端
xxxx@localhost:~# docker -v Docker version 19.03.8, build afacb8b