重新启动容器后,Keycloak Docker容器无法启动 [英] Keycloak Docker container fails to start after restarting the container

查看:841
本文介绍了重新启动容器后,Keycloak Docker容器无法启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Keycloak安装程序在docker-compose环境中作为docker容器运行.每天晚上,我的备份都会停止相关的容器,执行数据库和卷备份,然后再次重新启动容器.在大多数情况下,它都有效,但是Keycloak似乎有问题,此后不再出现.查看日志,错误消息是:

I have a Keycloak installation running as docker container in a docker-compose environment. Every night, my backup stops relevant containers, performs a DB and volume backup and restarts the containers again. For most it works, but Keycloak seems to have a problem with it and does not come up again afterwards. Looking at the logs, the error message is:

The batch failed with the following error: : 
keycloak           | WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:
keycloak           | Step: step-9
keycloak           | Operation: /subsystem=datasources/jdbc-driver=postgresql:add(driver-name=postgresql, driver-module-name=org.postgresql.jdbc, driver-xa-datasource-class-name=org.postgresql.xa.PGXADataSource)
keycloak           | Failure: WFLYCTL0212: Duplicate resource [
keycloak           |     ("subsystem" => "datasources"),
keycloak           |     ("jdbc-driver" => "postgresql")
keycloak           | ]
...
The batch failed with the following error: : 
keycloak           | WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:
keycloak           | Step: step-9
keycloak           | Operation: /subsystem=datasources/jdbc-driver=postgresql:add(driver-name=postgresql, driver-module-name=org.postgresql.jdbc, driver-xa-datasource-class-name=org.postgresql.xa.PGXADataSource)
keycloak           | Failure: WFLYCTL0212: Duplicate resource [
keycloak           |     ("subsystem" => "datasources"),
keycloak           |     ("jdbc-driver" => "postgresql")
keycloak           | ]

Keycloak的docker-compose.yml条目如下所示,重要数据已明显删除

The docker-compose.yml entry for Keycloak looks as follows, important data obviously removed

  keycloak:
    image: jboss/keycloak:8.0.1
    container_name: keycloak
    environment:
      - PROXY_ADDRESS_FORWARDING=true
      - DB_VENDOR=postgres
      - DB_ADDR=db
      - DB_DATABASE=keycloak
      - DB_USER=keycloak
      - DB_PASSWORD=<password>
      - VIRTUAL_HOST=<url>
      - VIRTUAL_PORT=8080
      - LETSENCRYPT_HOST=<url>
    volumes:
      - /opt/docker/keycloak-startup:/opt/jboss/startup-scripts

我要映射的卷在那里对WildFly进行了一些更改,以确保它在反向代理中表现良好:

The volume I'm mapping is there to make some changes to WildFly to make sure it behaves well with the reverse proxy:

embed-server --std-out=echo

#  Enable https listener for the new security realm
/subsystem=undertow/ \
  server=default-server/ \
    http-listener=default \
      :write-attribute(name=proxy-address-forwarding, \
                       value=true)

#  Create new socket binding with proxy https port
/socket-binding-group=standard-sockets/ \
  socket-binding=proxy-https \
    :add(port=443)

#  Enable https listener for the new security realm
/subsystem=undertow/ \
  server=default-server/ \
    http-listener=default \
      :write-attribute(name=redirect-socket, \
                       value="proxy-https")

停止容器后,不再显示上述消息以启动容器.但是,删除容器并重新创建它可以正常工作.我尝试在初次启动后删除该卷,但这也没什么大不了.我已经了解到,在初次启动后必须删除KEYCLOAK_USER=adminKEYCLOAK_PASSWORD环境变量,否则容器会抱怨该用户已经存在并且不再启动.知道如何解决该问题吗?

After stopping the container, its not starting anymore with the messages shown above. Removing the container and re-creating it works fine however. I tried to remove the volume after the initial start, this doesn't really make a difference either. I already learned that I have to remove the KEYCLOAK_USER=admin and KEYCLOAK_PASSWORD environment variables after the initial boot as otherwise the container complains that the user already exists and doesn't start anymore. Any idea how to fix that?

推荐答案

根据RedHat支持,这是已知的问题".并且不应该被修复.他们希望专注于删除和重新创建容器而不是启动和停止容器的工作流程.他们同意普遍存在的问题,但表示目前没有可用资源.停止和启动容器是当前不支持的操作.

According to RedHat support, this is a known "issue" and not supposed to be fixed. They want to concentrate on a workflow where a container is removed and recreated, not started and stopped. They agreed with the general problem, but stated that currently there are no resources available. Stopping and starting the container is a operation which is currently not supported.

例如参见 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆