如何使用CLI将模块添加到Wildfly [英] How to add module to Wildfly using CLI

查看:143
本文介绍了如何使用CLI将模块添加到Wildfly的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用postgres数据源创建一个Wildfly码头图像。

I'm trying to create a Wildfly docker image with a postgres datasource.

当我建立docker文件时,它总是失败,当我尝试安装postgres模块。

When I build the dockerfile it always fails with Permission Denied when I try to install the postgres module.

我的dockerfile看起来像这样:

My dockerfile looks look this:

FROM wildflyext/wildfly-camel

RUN /opt/jboss/wildfly/bin/add-user.sh admin admin --silent
ADD postgresql-9.4-1201.jdbc41.jar /tmp/
ADD config.sh /tmp/
ADD batch.cli /tmp/
RUN /tmp/config.sh

其中调用以下内容:

#!/bin/bash

JBOSS_HOME=/opt/jboss/wildfly
JBOSS_CLI=$JBOSS_HOME/bin/jboss-cli.sh
JBOSS_MODE=${1:-"standalone"}
JBOSS_CONFIG=${2:-"$JBOSS_MODE.xml"}

function wait_for_wildfly() {
  until `$JBOSS_CLI -c "ls /deployment" &> /dev/null`; do
    sleep 10
  done
}

echo "==> Starting WildFly..."
$JBOSS_HOME/bin/$JBOSS_MODE.sh -c $JBOSS_CONFIG > /dev/null &

echo "==> Waiting..."
wait_for_wildfly

echo "==> Executing..."
$JBOSS_CLI -c --file=`dirname "$0"`/batch.cli  --connect

echo "==> Shutting down WildFly..."
if [ "$JBOSS_MODE" = "standalone" ]; then
  $JBOSS_CLI -c ":shutdown"
else
  $JBOSS_CLI -c "/host=*:shutdown"
fi

batch

module add --name=org.postgresql --resources=/tmp/postgresql-9.4-1201.jdbc41.jar --dependencies=javax.api,javax.transaction.api
/subsystem=datasources/jdbc-driver=postgresql:add(driver-name=postgresql,driver-module-name=org.postgresql,driver-xa-datasource-class-name=org.postgresql.xa.PGXADataSource)

run-batch

建立时的输出是:

==>启动WildFly ...
==>等待...
==>执行...无法找到文件系统上的文件copy / tmp /postgresql-9.4-1201.jdbc41.jar到
/opt/jboss/wildfly/modules/org/postgresql/main/postgresql-9.4-1201.jdbc41.jar:
/tmp/postgresql-9.4 -1201.jdbc41.jar(Permission denied)

==> Starting WildFly... ==> Waiting... ==> Executing... Failed to locate the file on the filesystem copying /tmp/postgresql-9.4-1201.jdbc41.jar to /opt/jboss/wildfly/modules/org/postgresql/main/postgresql-9.4-1201.jdbc41.jar: /tmp/postgresql-9.4-1201.jdbc41.jar (Permission denied)

需要什么权限,设置权限?

What permissions are required, and where do I set the permission(s)?

谢谢

推荐答案

JAR文件不可由 jboss 用户(从父图像转换的用户)读取。在root用户下添加 postgresql-9.4-1201.jdbc41.jar - 在此GitHub讨论

It seems the JAR file is not readable by the jboss user (the user comming from parent image). The postgresql-9.4-1201.jdbc41.jar is added under the root user - find details in this GitHub discussion.

您可以


  • 在添加到图像之前添加JAR文件的权限

  • 或添加权限后添加到图像中的JAR文件

  • 或更改图像中文件的所有权

最简单的解决方案可能是第一个。另外2个解决方案还需要将用户切换到root( USER root 在dockerfile中),然后返回到jboss。

The simplest solution could be the first one. The other 2 solutions need also switching user to root (USER root in dockerfile) and then back to jboss.

这篇关于如何使用CLI将模块添加到Wildfly的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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