Install oracle 12c in docker under Mac

1. Use dockerID to log in to docker hub, if not, you need to register

2. Visit the oracle image address: https://store.docker.com/images/oracle-database-enterprise-edition

3. After filling in the information, you can see the installation instructions.

4. After logging in to docker, download the image

docker login
docker pull store/oracle/database-enterprise:12.2.0.1

5. Create a container

mkdir ~/orcl
docker run -d --name oracle -p 1521:1521 -p 5500:5500 -v ~/orcl:/ORCL store/oracle/database-enterprise:12.2.0.1

 

6. Check whether the log is successful

docker logs -f oracle

7. During the installation process, the error of http_proxy was encountered

Configure DB as oracle user
Setup Database directories ...
Error 46 initializing SQL*Plus
HTTP proxy setting has incorrect value
SP2-1502: The HTTP proxy server specified by http_proxy is not accessible
update password

Enter password for SYS: 
create pdb : ORCLPDB1
Error 46 initializing SQL*Plus
HTTP proxy setting has incorrect value
SP2-1502: The HTTP proxy server specified by http_proxy is not accessible
Reset Database parameters
Error 46 initializing SQL*Plus
HTTP proxy setting has incorrect value
SP2-1502: The HTTP proxy server specified by http_proxy is not accessible

The solution is as follows, set http_proxy to be empty in the environment variable

Create ~/orcl/DB_ENV file with the following content

DB_SID=ORCLCDB
DB_DOMAIN=localdomain
DB_MEMORY=4G
DB_PDB=ORCLPDB1
http_proxy=

Note the last line, http_proxy is empty

The Oracle Database Server container also provides custom configuration parameters for starting the container. All custom configuration parameters are optional.

DB_SID
This parameter changes the ORACLE_SID of the database. The default value is set to ORCLCDB.

DB_PDB
This parameter modifies the name of the PDB. The default value is set to ORCLPDB1.

DB_MEMORY
This parameter sets the memory requirements of the Oracle server. This value determines the amount of memory to allocate for the SGA and PGA. The default value is set to 2GB.

DB_DOMAIN
This parameter sets the domain to be used for the database server. The default value is localdomain.

Make sure the configuration in tnsnames.ora is consistent with DB_SID, DB_PDB and DB_DOMAIN.

 

8. Delete the directory (there may be other problems if not deleted)

docker stop oracle
docker rm  oracle
rm -rf ~/orcl
mkdir ~/orcl

9. Recreate the container using environment variables

docker run -d --name oracle  -p 1521:1521 -p 5500:5500 -v  /Users/apple/orcl:/ORCL --env-file /Users/apple/orcl/DB_ENV store/oracle/database-enterprise:12.2.0.1

10. The startup is successful and the status is healthy

docker ps
CONTAINER ID        IMAGE                                       COMMAND                  CREATED             STATUS                    PORTS                                            NAMES
bc5b66e114fb        store/oracle/database-enterprise:12.2.0.1   "/bin/sh -c '/bin/..."   33 minutes ago      Up 33 minutes (healthy)   0.0.0.0:1521->1521/tcp, 0.0.0.0:5500->5500/tcp   oracle

11. Modify the default password of sys

docker exec -it oracle bash
sqlplus / as sysdba
alter user sys identified by my_password

Note: The default password for sys is Oradoc_db1

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325027627&siteId=291194637