Docker buildx arm64


I’m trying to build a docker image starting from Quay, and importing a realm.json file. I do this on a MacBook amd64 with buildx to also provide a arm64 build for newer M1 macs. The amd64 is OK, as expected, but while importing the realm during the arm64 build, I get an error.

Any ideas what I am doing wrong?

Docker buildx:
docker buildx create --use --name mybuild
docker buildx build --platform linux/amd64,linux/arm64 .




ADD ./my-realm.json /tmp/my-realm.json

RUN ["/opt/keycloak/bin/", "import", "--file","/tmp/my-realm.json"]


> [linux/arm64 3/3] RUN ["/opt/keycloak/bin/", "import", "--file","/tmp/my-realm.json"]:                                                                                                                                                                              
#0 35.83 2022-04-04 06:02:31,287 INFO  [org.keycloak.quarkus.runtime.hostname.DefaultHostnameProvider] (main) Hostname settings: FrontEnd: <request>, Strict HTTPS: false, Path: <request>, Strict BackChannel: false, Admin: <request>, Port: -1, Proxied: false             
#0 42.47 2022-04-04 06:02:37,947 INFO  [org.infinispan.server.core.transport.EPollAvailable] (keycloak-cache-init) ISPN005028: Native Epoll transport not available, using NIO instead: java.lang.UnsatisfiedLinkError: could not load a native library: netty_transport_native_epoll_aarch_64                                                                                                                                                                                                                                                              
#0 43.25 2022-04-04 06:02:38,731 WARN  [org.infinispan.PERSISTENCE] (keycloak-cache-init) ISPN000554: jboss-marshalling is deprecated and planned for removal                                                                                                                 
#0 44.02 2022-04-04 06:02:39,497 WARN  [org.infinispan.CONFIG] (keycloak-cache-init) ISPN000569: Unable to persist Infinispan internal caches as no global state enabled
#0 44.50 2022-04-04 06:02:39,972 INFO  [org.infinispan.CONTAINER] (keycloak-cache-init) ISPN000556: Starting user marshaller 'org.infinispan.jboss.marshalling.core.JBossUserMarshaller'
#0 47.32 2022-04-04 06:02:42,795 INFO  [org.infinispan.CONTAINER] (keycloak-cache-init) ISPN000128: Infinispan version: Infinispan 'Triskaidekaphobia' 13.0.6.Final
#0 48.23 2022-04-04 06:02:43,719 INFO  [org.infinispan.CLUSTER] (keycloak-cache-init) ISPN000078: Starting JGroups channel `ISPN`
#0 48.24 2022-04-04 06:02:43,723 INFO  [org.infinispan.CLUSTER] (keycloak-cache-init) ISPN000088: Unable to use any JGroups configuration mechanisms provided in properties {}. Using default JGroups configuration!
#0 48.97 2022-04-04 06:02:44,457 ERROR [org.jgroups.protocols.UDP] (keycloak-cache-init) failed setting interface to / Protocol not available (Error setting socket option)
#0 48.98 2022-04-04 06:02:44,463 ERROR [org.jgroups.protocols.UDP] (keycloak-cache-init) failed setting interface to / Protocol not available (Error setting socket option)
#0 50.69 2022-04-04 06:02:46,171 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start server in (import_export) mode
#0 50.69 2022-04-04 06:02:46,176 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start caches
#0 50.69 2022-04-04 06:02:46,181 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: org.infinispan.manager.EmbeddedCacheManagerStartupException: org.infinispan.commons.CacheException: Unable to start JGroups Channel
#0 50.70 2022-04-04 06:02:46,182 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: org.infinispan.commons.CacheException: Unable to start JGroups Channel
#0 50.70 2022-04-04 06:02:46,185 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Unable to start JGroups Channel
#0 50.70 2022-04-04 06:02:46,187 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Protocol not available
#0 50.70 2022-04-04 06:02:46,189 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) For more details run the same command passing the '--verbose' option. Also you can use '--help' to see the details about the usage of the particular command.
WARNING: No output specified for docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
   5 |     ADD ./my-realm.json /tmp/my-realm.json
   6 |     
   7 | >>> RUN ["/opt/keycloak/bin/", "import", "--file","/tmp/my-realm.json"]
   8 |     
error: failed to solve: process "/opt/keycloak/bin/ import --file /tmp/my-realm.json" did not complete successfully: exit code: 1

Hi, I am also on MacBook Air with M1 Chip. I could build and import a my-realm.json by adding this to the Dockerfile (no ADD and no ENV), see also: Importing and Exporting Realms - Keycloak

Copy realm:

COPY ./my-realm.json /opt/keycloak/data/import/

Start in Production Mode

ENTRYPOINT ["/opt/keycloak/bin/", “start --import-realm”]

BTW, I am using a “docker-compose build” command.

Hope it helps. Remark: I am new to Keycloak and have to migrate from Keycloak (Wildfly) to Keycloak.X (Quarkus). => The documentation for migration could contain more valuable simple examples BEFORE-AFTER, for subjects like “Import a realm”, “Configure a custom SPI provider”, “Load application profile/properties”. It costs hours and hours to find out somewhere:face_vomiting: