gvenzl / oci-oracle-xe

Build scripts for Oracle Database XE container/docker images

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

colima: cannot connect to port 1521 from outside the container

vadakr opened this issue · comments

@gvenzl first, many thanks for the image!

I'm trying to get gvenzl/oracle-xe going on an M1 MacBook Pro using colima. I already run Microsoft SQL Server on the same setup and performance has not really been an issue.

% colima list
PROFILE    STATUS     ARCH      CPUS    MEMORY    DISK     RUNTIME    ADDRESS
default    Running    x86_64    4       12GiB     60GiB    docker
 % docker ps -a
CONTAINER ID   IMAGE                                        COMMAND                  CREATED         STATUS         PORTS                                       NAMES
e4bbd07e6234   gvenzl/oracle-xe                             "container-entrypoin…"   6 minutes ago   Up 6 minutes   0.0.0.0:1521->1521/tcp, :::1521->1521/tcp   oraxe
21e9f2149dfe   mcr.microsoft.com/mssql/server:2022-latest   "/opt/mssql/bin/perm…"   3 months ago    Up 3 weeks     0.0.0.0:1433->1433/tcp, :::1433->1433/tcp   mssql22

This is how I installed -

% docker volume create oradata
oradata
% docker run -d -p 1521:1521 -e ORACLE_PASSWORD=test --mount source=oradata,target=/opt/oracle/oradata -v /Users/xxx/Docker/ora-bak:/opt/bak --name oraxe -h oraxe gvenzl/oracle-xe
e4bbd07e6234b1b1dbf13e863c0681bdb07f00a5b0c3e4a05cf9183974ee6c3b
% docker logs oraxe -f
CONTAINER: starting up...
CONTAINER: first database startup, initializing...
CONTAINER: uncompressing database data files, please wait...
CONTAINER: done uncompressing database data files, duration: 47 seconds.
CONTAINER: starting up Oracle Database...

LSNRCTL for Linux: Version 21.0.0.0.0 - Production on 02-MAR-2023 22:43:02

Copyright (c) 1991, 2021, Oracle.  All rights reserved.

Starting /opt/oracle/product/21c/dbhomeXE/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 21.0.0.0.0 - Production
System parameter file is /opt/oracle/homes/OraDBHome21cXE/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/oraxe/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 21.0.0.0.0 - Production
Start Date                02-MAR-2023 22:43:02
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           XE
Listener Parameter File   /opt/oracle/homes/OraDBHome21cXE/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/oraxe/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
The listener supports no services
The command completed successfully
ORACLE instance started.

Total System Global Area 1241512272 bytes
Fixed Size		    9685328 bytes
Variable Size		  570425344 bytes
Database Buffers	  654311424 bytes
Redo Buffers		    7090176 bytes
Database mounted.
Database opened.

CONTAINER: Resetting SYS and SYSTEM passwords.

User altered.


User altered.


#########################
DATABASE IS READY TO USE!
#########################

##################################################################
CONTAINER: The following output is now from the alert_XE.log file:
##################################################################
2023-03-02T22:43:31.955942+00:00
XEPDB1(3):SUPLOG: Set PDB SUPLOG SGA at PDB OPEN, old 0x18, new 0x0 (no suplog)
2023-03-02T22:43:36.758264+00:00
XEPDB1(3):Opening pdb with Resource Manager plan: DEFAULT_PLAN
Pluggable database XEPDB1 opened read write
2023-03-02T22:43:38.311134+00:00
Starting background process CJQ0
Completed: ALTER DATABASE OPEN
2023-03-02T22:43:38.368808+00:00
CJQ0 started with pid=60, OS id=224
^C

I can go into the container and connect to XEPDB1 -

% docker exec -it oraxe sh
sh-4.4$ sqlplus sys/test@XEPDB1 as sysdba


SQL*Plus: Release 21.0.0.0.0 - Production on Thu Mar 2 22:52:46 2023
Version 21.3.0.0.0

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


Connected to:
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0

SQL>

But I cannot connect to it from outside the container. When I try to connect to jdbc:oracle:thin:@//localhost:1521/XEPDB1, I get -

IO Error: The Network Adapter could not establish the connection (CONNECTION_ID=n4BYVXv8Rc2DS0dj1jx3pA==).

So I checked netstat to see if anything was listening on 1521, and sure enough, nothing was -

% netstat -an | grep 1521
<nothing>

SQL Server listens on 1433 and netstat confirms that -

% netstat -an | grep 1433
tcp4       0      0  127.0.0.1.1433         127.0.0.1.55334        ESTABLISHED
tcp4       0      0  127.0.0.1.1433         127.0.0.1.55333        ESTABLISHED
tcp4       0      0  127.0.0.1.55334        127.0.0.1.1433         ESTABLISHED
tcp4       0      0  127.0.0.1.55333        127.0.0.1.1433         ESTABLISHED
tcp4       0      0  127.0.0.1.1433         127.0.0.1.57586        ESTABLISHED
tcp4       0      0  127.0.0.1.57586        127.0.0.1.1433         ESTABLISHED
tcp4       0      0  127.0.0.1.1433         127.0.0.1.57585        ESTABLISHED
tcp4       0      0  127.0.0.1.57585        127.0.0.1.1433         ESTABLISHED
tcp4       0      0  *.1433                 *.*                    LISTEN

So to troubleshoot the container, I installed netstat into it using -

% docker exec -it -u root oraxe sh
sh-4.4# microdnf install net-tools
sh-4.4# netstat -an | grep 1521
tcp        0      0 0.0.0.0:1521            0.0.0.0:*               LISTEN
tcp        0      0 172.17.0.3:1521         172.17.0.3:48394        ESTABLISHED
tcp        0      0 172.17.0.3:48394        172.17.0.3:1521         ESTABLISHED

For those wondering, 172.17.0.3 is the local/container IP-

sh-4.4# ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.3  netmask 255.255.0.0  broadcast 172.17.255.255

Everything appears to be OK, but I can't connect to port 1521 from the outside. So I thought maybe this is a Colima issue. I did find this https://stackoverflow.com/questions/72810369/docker-not-listening-on-port-on-osx-colima, but the solution is already in effect -

% colima start --network-address
WARN[0000] already running, ignoring

I even tried mapping a different port i.e. docker xxx -p 51521:1521, but no difference in behavior.

I'm out of ideas, any help is appreciated!

I restarted my Mac as a last resort and that fixed it!

Glad to hear you got it fixed, @vadakr!