How to add module to Wildfly using CLI

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

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

  • use cloudera with docker-compose
  • SSH tunneling to remote server with docker
  • How to run a pool of Docker containers on a single host preserving their IP address on restart?
  • Why didn't docker copy files to the mounted directory?
  • Docker-compose extend not finding environment variables
  • Percona 5.6 Docker Image cannot load my /etc/mysql/conf.d/*.cnf
  • My dockerfile looks look this:

    FROM wildflyext/wildfly-camel
    RUN /opt/jboss/wildfly/bin/ admin admin --silent
    ADD postgresql-9.4-1201.jdbc41.jar /tmp/
    ADD /tmp/
    ADD batch.cli /tmp/
    RUN /tmp/

    Which calls the following:

    function wait_for_wildfly() {
      until `$JBOSS_CLI -c "ls /deployment" &> /dev/null`; do
        sleep 10
    echo "==> Starting WildFly..."
    $JBOSS_HOME/bin/$ -c $JBOSS_CONFIG > /dev/null &
    echo "==> Waiting..."
    echo "==> Executing..."
    $JBOSS_CLI -c --file=`dirname "$0"`/batch.cli  --connect
    echo "==> Shutting down WildFly..."
    if [ "$JBOSS_MODE" = "standalone" ]; then
      $JBOSS_CLI -c ":shutdown"
      $JBOSS_CLI -c "/host=*:shutdown"


    module add --name=org.postgresql --resources=/tmp/postgresql-9.4-1201.jdbc41.jar --dependencies=javax.api,javax.transaction.api

    The output when building is:

    ==> Starting WildFly…
    ==> Waiting…
    ==> Executing… Failed to locate the file on the filesystem copying /tmp/postgresql-9.4-1201.jdbc41.jar to
    /tmp/postgresql-9.4-1201.jdbc41.jar (Permission denied)

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


  • Troubles using docker-machine to setup Swarm
  • Docker Swarm: How to Sniff Network Traffic
  • What are the differences between a VM image and a Docker image? [duplicate]
  • How to move a volume from to a new docker container?
  • manage containers from another container, docker
  • Rsync not working between the openshift containers based on rhel7.3
  • 2 Solutions collect form web for “How to add module to Wildfly using CLI”

    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.

    You could

    • either add permissions to JAR file before adding it to the image
    • or add permissions to JAR file in the image after the adding
    • or change ownership of the file in the image

    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.

    Here a advice : make a cli file like this :

    module add --name=sqlserver.jdbc --resources=@INSTALL_FOLDER@/libext/jtds-1.3.1.jar --dependencies=javax.api,javax.transaction.api

    replace @VAR@ by our own value… and It should work!
    Be caution than JBOSS/Wildfly 10 think relatively for jar –resources by default but wildfly 8 think absolute path this could make you weird ! 😉


    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.