gvenzl / oci-oracle-xe

Build scripts for Oracle Database XE container/docker images
Apache License 2.0
269 stars 77 forks source link

Running Oracle XE on Apple M1 not working (ORA-12547: TNS:lost contact) #63

Closed XavierLevaux closed 2 years ago

XavierLevaux commented 2 years ago

Hi!

I tried starting Oracle XE on Docker 20.10.10 on an Apple M1 computer.

docker run -p 1521:1521 -e ORACLE_PASSWORD=pwd --platform linux/amd64 gvenzl/oracle-xe

Here is my docker info:

Client:
 Cloud integration: v1.0.20
 Version:           20.10.10
 API version:       1.41
 Go version:        go1.16.9
 Git commit:        b485636
 Built:             Mon Oct 25 07:43:15 2021
 OS/Arch:           darwin/arm64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.10
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.9
  Git commit:       e2f740d
  Built:            Mon Oct 25 07:41:10 2021
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.4.11
  GitCommit:        5b46e404f6b9f661a205e28d59c982d3634148f8
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

It fails whith the following log:

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

ERROR:

ORA-12547: TNS:lost contact

SP2-0306: Invalid option.

Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] [edition=value]]

where <logon> ::= <username>[/<password>][@<connect_identifier>]

      <proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]

SP2-0306: Invalid option.

Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] [edition=value]]

where <logon> ::= <username>[/<password>][@<connect_identifier>]

      <proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]

SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus

Is Oracle XE not yet working on Apple M1?

Thanks!

gvenzl commented 2 years ago

Hi @XavierLevaux, according to https://github.com/oracle/docker-images/discussions/1951 it is currently not possible to run Oracle Database on ARM chipsets. I have heard that Apple has an x86 emulator that should automatically take care of x86 apps running on M1 but given that I do not have an M1 Mac myself yet, I cannot confirm or deny that.

cofin commented 2 years ago

@gvenzl @XavierLevaux I am also trying to get this running on Apple silicon. I have specified the --platform linux/amd64 attribute to tell Docker to emulate x86, but I am getting the same error as above. I'll try to run buildx locally to see if that makes a difference, and I'll report any findings.

Additionally, I'm willing to run any tests or gather additional diagnostics if anyone has ideas on how to make it work.

tomdevroomen commented 2 years ago

Same issue on my new M1 machine. Have been able to find a workaround, @cofin ?

cofin commented 2 years ago

No. I should have come back to post my findings. I tried to build with different versions of XE with no luck. All resulted in the same TNS error.

I may have to resort to a UTM based Linux VM until there is an acceptable alternative.

gvenzl commented 2 years ago

Thanks a lot for your research on this, @cofin! It is highly appreciated!

rathboma commented 2 years ago

I just ran into the same problem :-(. @gvenzl any chance you could add a note about the apple/arm compatibility problems to your dockerhub docs?

gvenzl commented 2 years ago

There has been some movement over on https://github.com/oracle/docker-images/discussions/1951 in the meantime. It seems that users are able to spin up Oracle databases by using a Docker Desktop alternative called colima. Unfortunately, I still don't have an M1 Mac so I cannot verify myself but if anybody would be able to verify the approach reported over there, I would be deeply grateful.

The solution seems to be:

brew install colima
brew install docker
colima start --memory 4 --arch x86_64
docker run ...
salah3x commented 2 years ago

The above-mentioned solution is working perfectly 👍

gvenzl commented 2 years ago

Awesome, thanks so much for confirming, @salah3x!

tomdevroomen commented 2 years ago

I can confirm it also works running on UTM and lima

gvenzl commented 2 years ago

Great, thanks a lot, @tomdevroomen!

I would like to add some generic info about how to run these images on Mac M1 into the ReadMe. But given that I am not running on an M1 myself, I'm not entirely sure what method would be the most acceptable to M1 users.

I assume removing Docker Desktop and installing colima means that all images running on that Mac M1 will have to be x86_64 images? Would that cause any unwanted side effects, other than not wanting to run an x86_64 image when an arm64 is available?

tomdevroomen commented 2 years ago

I've got lima running besides docker desktop. Via docker context you're able to choose to run docker commands through lima. I'm using your image within a testcontainers setup, but all those workarounds aren't compatible with testcontainers

Steps to setup with UTM, but compared to (co)lima it is more work and in my experience also slower. apple-silicon-database-installation.md

Think I'll replace my lima installation with colima, as that's exactly what I need from lima :)

tomdevroomen commented 2 years ago

setup with colima:

You should give it some time to start up, but I was able to start up the full version.

salah3x commented 2 years ago

@tomdevroomen

but all those workarounds aren't compatible with testcontainers

I was able to make it work w/ testcontainers, the idea is to make sure /var/run/docker.sock is accessible. It's symlinked to ~/.colima/default/docker.sock when starting colima, but double-check it anyway (I had to loosen up the permissions on the file to make it work). Running colima status should print the original path of the docker socket, u can also use that to customize testcontainers' host detection.

tomdevroomen commented 2 years ago

@tomdevroomen

but all those workarounds aren't compatible with testcontainers

I was able to make it work w/ testcontainers, the idea is to make sure /var/run/docker.sock is accessible. It's symlinked to ~/.colima/default/docker.sock when starting colima, but double-check it anyway (I had to loosen up the permissions on the file to make it work). Running colima status should print the original path of the docker socket, u can also use that to customize testcontainers' host detection.

I've tried the testcontainers host detection before, but I wasn't able to make it work. It was overwritten every time with the defaults when starting testcontainers.

I'll give the symlink a try.

tomdevroomen commented 2 years ago

@salah3x I've change the host detection for testcontainers, and it is picking up the colima docker.sock.
But it's unable to connect to the Ruyk container

08:13:33.943 [main] INFO  org.testcontainers.dockerclient.DockerClientProviderStrategy - Found Docker environment with Environment variables, system properties and defaults. Resolved dockerHost=unix:///Users/user/.colima/default/docker.sock
08:13:33.944 [main] INFO  org.testcontainers.DockerClientFactory - Docker host IP address is localhost
08:13:34.277 [main] INFO  org.testcontainers.DockerClientFactory - Connected to docker: 
  Server Version: 20.10.11
  API Version: 1.41
  Operating System: Alpine Linux v3.14
  Total Memory: 3938 MB
08:13:34.378 [main] INFO  org.testcontainers.utility.RegistryAuthLocator - Credential helper/store (docker-credential-desktop) does not have credentials for index.docker.io
08:13:37.693 [testcontainers-ryuk] WARN  org.testcontainers.utility.RyukResourceReaper - Can not connect to Ryuk at localhost:49154

How we you able to resolve this?

gvenzl commented 2 years ago

Hey all, I've been chatting with my friends at Testcontainers (wink, wink @kiview and @eddumelendez) and they have had other users bring up the question of colima, see here.

It appears, that with the following config, Testcontainers works just fine with colima:

export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock
export DOCKER_HOST="unix://${HOME}/.colima/docker.sock"
tomdevroomen commented 2 years ago

Hey all, I've been chatting with my friends at Testcontainers (wink, wink @kiview and @eddumelendez) and they have had other users bring up the question of colima, see here.

It appears, that with the following config, Testcontainers works just fine with colima:

export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock
export DOCKER_HOST="unix://${HOME}/.colima/docker.sock"

I can confirm this is working 🥳 🥳 🥳

gvenzl commented 2 years ago

Great, glad to hear that! :)

tomdevroomen commented 2 years ago

I've written 2 blogpost to summarise it all:

https://blog.jdriven.com/2022/07/running-oracle-xe-on-apple-silicon/ https://blog.jdriven.com/2022/07/running-oracle-xe-with-testcontainers-on-apple-silicon/

In both blogs I referred to your work @gvenzl

gvenzl commented 2 years ago

That's amazing, thanks so much for doing that, @tomdevroomen!

I have added the instructions into the ReadMe as well. Hopefully, this will help all other Apple M chip users to run these images!

jhswedeveloper commented 1 year ago

I've written 2 blogpost to summarise it all:

https://blog.jdriven.com/2022/07/running-oracle-xe-on-apple-silicon/ https://blog.jdriven.com/2022/07/running-oracle-xe-with-testcontainers-on-apple-silicon/

In both blogs I referred to your work @gvenzl

@tomdevroomen Hi have you had any perf issue? I've tried same setup but takes really long for my app to connect to oracle container once it is up and running. Used to take 20 sec, now more like 2 mins.

tomdevroomen commented 1 year ago

I've written 2 blogpost to summarise it all: https://blog.jdriven.com/2022/07/running-oracle-xe-on-apple-silicon/ https://blog.jdriven.com/2022/07/running-oracle-xe-with-testcontainers-on-apple-silicon/ In both blogs I referred to your work @gvenzl

@tomdevroomen Hi have you had any perf issue? I've tried same setup but takes really long for my app to connect to oracle container once it is up and running. Used to take 20 sec, now more like 2 mins.

Yes, there's a performance penaulty, as with colima virtualisation is used, so instructions need to be translated. But I take that for granted, as I have no other option.

Rosso84 commented 1 year ago

Worked with colima here as well, thanks!

p5t5r commented 1 year ago

Hi

It works fine, thanks! but after that all other docker images (here: redis, rabbit) were unusable and i had to create them as new ones and they are visible under 'docker ps' command but not in Docker desktop app. Docker App is empty. Correct?

kiview commented 1 year ago

The Docker Desktop GUI is in no way connected to Colima. The Docker CLI working with Colima probably works through the Docker context.

joc-a commented 1 year ago

I've written 2 blogpost to summarise it all:

https://blog.jdriven.com/2022/07/running-oracle-xe-on-apple-silicon/ https://blog.jdriven.com/2022/07/running-oracle-xe-with-testcontainers-on-apple-silicon/

In both blogs I referred to your work @gvenzl

Hi @tomdevroomen. I followed the steps in your first blog post, but I am still running into issues and I don't know what I'm missing. Would appreciate a second pair of eyes for this.

Here is my docker-compose YAML file:

version: '3.1'

services:
    oracle:
        container_name: oracleDB
        image: gvenzl/oracle-xe:18
        platform: linux/amd64
        ports:
            - "1521:1521"
        environment:
            ORACLE_PASSWORD: "StrongPassword"

And this is the log:

CONTAINER: starting up...
CONTAINER: first database startup, initializing...
CONTAINER: uncompressing database data files, please wait...
CONTAINER: done uncompressing database data files, duration: 14 seconds.
CONTAINER: starting up Oracle Database...

LSNRCTL for Linux: Version 18.0.0.0.0 - Production on 08-AUG-2023 10:06:26

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

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

TNSLSNR for Linux: Version 18.0.0.0.0 - Production
System parameter file is /opt/oracle/product/18c/dbhomeXE/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/17fe1d08dc70/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 18.0.0.0.0 - Production
Start Date                08-AUG-2023 10:06:26
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/product/18c/dbhomeXE/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/17fe1d08dc70/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
ERROR:
ORA-12547: TNS:lost contact

SP2-0306: Invalid option.
Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] 
where <logon> ::= <username>[/<password>][@<connect_identifier>]
      <proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]
SP2-0306: Invalid option.
Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] 
where <logon> ::= <username>[/<password>][@<connect_identifier>]
      <proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]
SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
CONTAINER: starting up...
CONTAINER: database already initialized.
CONTAINER: starting up Oracle Database...

LSNRCTL for Linux: Version 18.0.0.0.0 - Production on 08-AUG-2023 10:07:20

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

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

TNSLSNR for Linux: Version 18.0.0.0.0 - Production
System parameter file is /opt/oracle/product/18c/dbhomeXE/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/17fe1d08dc70/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 18.0.0.0.0 - Production
Start Date                08-AUG-2023 10:07:22
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/product/18c/dbhomeXE/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/17fe1d08dc70/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
ERROR:
ORA-12547: TNS:lost contact

SP2-0306: Invalid option.
Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] 
where <logon> ::= <username>[/<password>][@<connect_identifier>]
      <proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]
SP2-0306: Invalid option.
Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] 
where <logon> ::= <username>[/<password>][@<connect_identifier>]
      <proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]
SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
tomdevroomen commented 1 year ago

@joc-a Looks like you're still trying to run de oracle image with a default docker env.

ERROR: ORA-12547: TNS:lost contact is the exact message I got when running it on a default docker env. Make sure you run you compose file with the docker instance running on Colima. You can verify this with docker context list and having the active context pointing to the colima docker endpoint like this (the one with the * is the currently active one):

docker context list
NAME                TYPE                DESCRIPTION                               DOCKER ENDPOINT                                            KUBERNETES ENDPOINT   ORCHESTRATOR
colima              moby                colima                                    unix:///Users/user/.colima/default/docker.sock
default *           moby                Current DOCKER_HOST based configuration   unix:///Users/user/.colima/docker.sock

output of env | grep DOCKER_HOST should be

> env | grep DOCKER_HOST
DOCKER_HOST=unix:///Users/user/.colima/docker.sock

if this all doesn't point to colima, set the DOCKER_HOST, which is only active for the current shell where you're working in.

joc-a commented 1 year ago

@joc-a Looks like you're still trying to run de oracle image with a default docker env.

ERROR: ORA-12547: TNS:lost contact is the exact message I got when running it on a default docker env. Make sure you run you compose file with the docker instance running on Colima. You can verify this with docker context list and having the active context pointing to the colima docker endpoint like this (the one with the * is the currently active one):

docker context list
NAME                TYPE                DESCRIPTION                               DOCKER ENDPOINT                                            KUBERNETES ENDPOINT   ORCHESTRATOR
colima              moby                colima                                    unix:///Users/user/.colima/default/docker.sock
default *           moby                Current DOCKER_HOST based configuration   unix:///Users/user/.colima/docker.sock

output of env | grep DOCKER_HOST should be

> env | grep DOCKER_HOST
DOCKER_HOST=unix:///Users/user/.colima/docker.sock

if this all doesn't point to colima, set the DOCKER_HOST, which is only active for the current shell where you're working in.

@tomdevroomen I set up everything exactly as explained in your reply, but I'm still getting ORA-12547: TNS:lost contact.

Sneang1 commented 1 year ago

Hi, may I ask for your help? I got * at the end of colima but I still not error " ERROR: ORA-12541: TNS:no listener" could you help me to solve this problem? I used M1 Chip. I thank you in advance

VladRoscaDev commented 9 months ago

Based on this new image: https://github.com/oracle/docker-images/discussions/1951#discussioncomment-6939131 Is there a chance we would get it ?

They also stated : " container-registry.oracle.com/database/enterprise:19.19.0.0 is only built for linux/arm64 currently."