[docker] run oracle 11g in docker

1.  find docker file and pull

1.1. docker search oracle

search docker images or you can also search oracle-11g at github.

1.2 docker pull jaspeen/oracle-11g

2.  download oracle 11g linux install file from oracle website and extract to <install_folder>, make sure under the <install_folder>, the extracted folder is "database".

  <install_folder>
    └─database
        ├─doc
        ├─install
        ├─response
        ├─rpm
        ├─sshsetup
        ├─stage
        ├─runInstaller
        └─welcome.html

and under the above example folder, the directory tree would show "install"... etc.

ps: make sure it's linux version even you are in windows and mac os.

3. install oracle-11g with docker

docker run --privileged --name oracle11g -p 1521:1521 -v /home:/install jaspeen/oracle-11g

 /home is the <install_folder>

there's gonna be a lot of logs printed, make sure to wait installation period finished with 100% prompted.

and after that, other logs would also be prompt, just open anther terminal to exit it.

to check the installation status:

  docker ps -a

CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS                      PORTS                                                                             NAMES
7f53f07c93e5        jaspeen/oracle-11g   "/assets/entrypoint...."   About an hour ago   Up About an hour            0.0.0.0:1521->1521/tcp, 8080/tcp                                                  oracle11g

in any case, if the installation come with exception, just remove the container with tag or image id:

docker rm oracle11g

or

docker ps -l

docker rm ******

4. run the docker image 

just in case container not running after above commands, try:

docker start -i oracle11g

5. run with command

docker exec -it container_id(oracle11g)  [command]

eg: docker exec -it oracle11g /bin/bash

6. switch to sudo user

su - oracle

7. login in with sysdba

sqlplus / as sysdba

8. unlock account

after login with sysdba, unlock scott with:

alter user scott account unlock

9. connecft with scott

conn scott/tiger

after login in with scott, you need to enter new password(can be same with old password).

10. connect with IDE, such as sql developer

ip: localhost

port:1521

sid: orcl

宛如智障,暗藏锋芒
原文地址:https://www.cnblogs.com/zienzir/p/13612816.html