title: How to add module to Wildfly using CLI
body: <p>I'm trying to create a Wildfly docker image with a postgres datasource.</p>
  
  <p>When I build the dockerfile it always fails with Permission Denied when I try to install the postgres module.</p>
  
  <p>My dockerfile looks look this:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Which calls the following:</p>
  
  <pre><code>#!/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" &amp;&gt; /dev/null`; do
      sleep 10
    done
  }
  
  echo "==&gt; Starting WildFly..."
  $JBOSS_HOME/bin/$JBOSS_MODE.sh -c $JBOSS_CONFIG &gt; /dev/null &amp;
  
  echo "==&gt; Waiting..."
  wait_for_wildfly
  
  echo "==&gt; Executing..."
  $JBOSS_CLI -c --file=`dirname "$0"`/batch.cli  --connect
  
  echo "==&gt; Shutting down WildFly..."
  if [ "$JBOSS_MODE" = "standalone" ]; then
    $JBOSS_CLI -c ":shutdown"
  else
    $JBOSS_CLI -c "/host=*:shutdown"
  fi
  </code></pre>
  
  <p>And </p>
  
  <pre><code>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
  </code></pre>
  
  <p>The output when building is:</p>
  
  <blockquote>
    <p>==> 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)</p>
  </blockquote>
  
  <p>What permissions are required, and where do I set the permission(s)?</p>
  
  <p>Thanks</p>