如何在Docker容器上运行keycloak?

s5a0g9ez  于 2024-01-06  发布在  Docker
关注(0)|答案(1)|浏览(125)

我尝试在docker容器上运行keycloak。我尝试了两种不同的方法运行它:
第一种解决方案:
下面的命令是from this link

docker run --name mykeycloak -p 8080:8080 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:latest start-dev

字符串
第二个解决方案,我试图通过Dockerfile运行它,它基本上做同样的事情:

# Use Keycloak's latest image as the base
FROM quay.io/keycloak/keycloak:23.0

    # Set environment variables for admin user
    ENV KEYCLOAK_ADMIN=admin \
        KEYCLOAK_ADMIN_PASSWORD=admin \
        KEYCLOAK_PROFILE_FEATURE_UPLOAD_SCRIPTS=enabled
    
    # Set the command to start Keycloak in dev mode and import the realm
    CMD ["start-dev", "--import-realm"]


构建镜像并在端口8080上运行构建的镜像非常容易。
在这两个解决方案中,我可以成功运行keycloak,下面是控制台中的日志:

[io.quarkus.deployment.QuarkusAugmentor] (main) Quarkus augmentation completed in 5414ms
2023-12-29 09:42:47,335 INFO  [org.keycloak.quarkus.runtime.hostname.DefaultHostnameProvider] (main) Hostname settings: Base URL: <unset>, Hostname: <request>, Strict HTTPS: false, Path: <request>, Strict BackChannel: false, Admin URL: <unset>, Admin: <request>, Port: -1, Proxied: false
2023-12-29 09:42:48,520 WARN  [io.quarkus.agroal.runtime.DataSources] (main) Datasource <default> enables XA but transaction recovery is not enabled. Please enable transaction recovery by setting quarkus.transaction-manager.enable-recovery=true, otherwise data may be lost if the application is terminated abruptly
2023-12-29 09:42:48,839 WARN  [org.infinispan.PERSISTENCE] (keycloak-cache-init) ISPN000554: jboss-marshalling is deprecated and planned for removal
2023-12-29 09:42:48,917 WARN  [org.infinispan.CONFIG] (keycloak-cache-init) ISPN000569: Unable to persist Infinispan internal caches as no global state enabled
2023-12-29 09:42:49,004 INFO  [org.infinispan.CONTAINER] (keycloak-cache-init) ISPN000556: Starting user marshaller 'org.infinispan.jboss.marshalling.core.JBossUserMarshaller'
2023-12-29 09:42:51,146 INFO  [org.keycloak.quarkus.runtime.storage.legacy.liquibase.QuarkusJpaUpdaterProvider] (main) Initializing database schema. Using changelog META-INF/jpa-changelog-master.xml

UPDATE SUMMARY
Run:                        117
Previously run:               0
Filtered out:                 0
-------------------------------
Total change sets:          117

2023-12-29 09:42:53,681 INFO  [org.keycloak.connections.infinispan.DefaultInfinispanConnectionProviderFactory] (main) Node name: node_597367, Site name: null
2023-12-29 09:42:53,747 INFO  [org.keycloak.broker.provider.AbstractIdentityProviderMapper] (main) Registering class org.keycloak.broker.provider.mappersync.ConfigSyncEventListener
2023-12-29 09:42:53,774 INFO  [org.keycloak.services] (main) KC-SERVICES0050: Initializing master realm
2023-12-29 09:42:55,037 INFO  [io.quarkus] (main) Keycloak 23.0.3 on JVM (powered by Quarkus 3.2.9.Final) started in 8.538s. Listening on: http://0.0.0.0:8080
2023-12-29 09:42:55,038 INFO  [io.quarkus] (main) Profile dev activated.
2023-12-29 09:42:55,038 INFO  [io.quarkus] (main) Installed features: [agroal, cdi, hibernate-orm, jdbc-h2, jdbc-mariadb, jdbc-mssql, jdbc-mysql, jdbc-oracle, jdbc-postgresql, keycloak, logging-gelf, micrometer, narayana-jta, reactive-routes, resteasy-reactive, resteasy-reactive-jackson, smallrye-context-propagation, smallrye-health, vertx]
2023-12-29 09:42:55,291 INFO  [org.keycloak.services] (main) KC-SERVICES0009: Added user 'admin' to realm 'master'
2023-12-29 09:42:55,296 WARN  [org.keycloak.quarkus.runtime.KeycloakMain] (main) Running the server in development mode. DO NOT use this configuration in production.


但是,当我尝试访问http://localhost:8080/auth/上的keyclaok时,控制台不可用:


的数据
我已经看了this question,但它没有帮助我。

p1iqtdky

p1iqtdky1#

1.对于这个版本的keycloak,即23.0,您应该使用http://localhost:8081/访问keycloak,因此,您必须删除路径末尾的单词auth
1.另外,请尝试禁用防火墙,看看它们是否阻止了任何请求

相关问题