I'm trying to install Oracle XE 18c in a docker container in Windows 10. I have docker already installed, and I need to build the image as explained here.

I cloned the git repository, but I'm stuck on this step, as what I cloned are Linux commands and not Windows.

After cloning with:

git clone https://github.com/oracle/docker-images.git

If I cd to docker-images\OracleDatabase\SingleInstance\dockerfiles\18.4.0 to build the image I see the following sh comands, instead of exe or bat:

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

How to build this image in Windows?

  • What's your Docker environment?. Docker Desktop or Docker Toolbox?
    – user168186
    Dec 28 '19 at 21:15

Use Wsl Ubuntu Bash set path to Docker executables or simply install Git Bash for Windows from Docker Tools and run the shell script from Git Bash terminal(I prefer Git Bash).Download and Copy Oracle18xe rpm file to 18.40 folder

This is output from Git Bash for windows

 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

After running shell script successfully

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 \
>     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,>1521/tcp,>5500/tcp   myxedb

You can connect to database via sqlplus or login into docker container using Windows Dos

    D:\>docker exec -it --user=oracle myxedb bash

[oracle@afce013adb98 /]$ . oraenv
The Oracle base remains unchanged with value /opt/oracle

[oracle@afce013adb98 /]$ sqlplus / as sysdba

    SQL*Plus: Release - Production on Sun Dec 29 05:04:32 2019

    Copyright (c) 1982, 2018, Oracle.  All rights reserved.

    Connected to:
    Oracle Database 18c Express Edition Release - Production

    SQL> select banner from v$version;

    Oracle Database 18c Express Edition Release - Production

P.S:-Make sure you logged into docker hub from git bash terminal docker login

To use WSL subsystem bash terminal add path and alias to .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

From WSL Bash terminal

xxxx@localhost:~# docker -v
Docker version 19.03.8, build afacb8b
  • Thanks for posting your answer. I downloaded the rpm, checked the sha-256 and put it in 18.4.0 directory, but when running the shell script I get md5sum: 'oracle-database-xe-18c-1.0-1.x86_64.rpm'$'\r': No such file or directory. The file name is correct, what's wrong?
    – ps0604
    Dec 29 '19 at 15:21
  • Yes that's correct one.Are you running the command ./buildDockerImage.sh -v 18.4.0 -x (it should be x at the end for Express edition).Work around is comment out validate packages in shell script.
    – user168186
    Dec 29 '19 at 17:21
  • adding -i to ignore the check sum worked
    – ps0604
    Dec 29 '19 at 18:10
  • Yes I realized that after posting that comment :-)
    – user168186
    Dec 29 '19 at 19:04
  • can you take a look at this? thanks
    – ps0604
    Feb 17 '20 at 18:13

Yes, I would really recommend using WSL or rather WSL 2 for Docker now.

But there is another (easier?) way to build you Oracle 18c Docker image with the official Dockerfiles (you might even use this way from inside WSL/ WSL2 if you see a need for this).

Do note that the (Linux/Bash) script buildDockerImage.sh is just a helper (checking the checksum and so on) building the command to call docker. You can build your image directly with the available Dockerfile, ie. Dockerfile.xe (in the case of 18.0.4).

From within the folder "18.4.0" (where you have also saved the database (Linux-Version!) downloaded from Oracle) enter:

docker build -t [image name of your choosing] -f Dockerfile.xe .

[be sure to include the . (dot) at the end because this tells docker "this folder"]

Do note that this takes roughly 40-50 minutes. I have done it this way (before WSL 2) and it worked for me quite well.

HTH Andreas

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.