[JAVA] Try WildFly with Docker

WildFly Official Image is published on Docker Hub, so use it to try WildFly.

Start-up

You can start it with the following command.

docker run -d --name demo -p 8080:8080 -p 9990:9990 \
    jboss/wildfly /opt/jboss/wildfly/bin/standalone.sh \
    -b=0.0.0.0 -bmanagement=0.0.0.0

8080 is the port that publishes the application and 9990 is the port of the management console.

I'm using /opt/jboss/wildfly/bin/standalone.sh because I'm running in standalone mode. If you start in domain mode, it's /opt/jboss/wildfly/bin/domain.sh.

I have added -b = 0.0.0.0 to the boot option, but without it I can't connect from outside the container (that is, I can't connect at http: // localhost: 8080). The same is true for -bmanagement = 0.0.0.0, which is an option for the management console.

After starting, add an administrative user. You can add an admin user with the username admin and password secret with the following command:

docker exec demo /opt/jboss/wildfly/bin/add-user.sh admin secret --silent

Once you have added an admin user, try opening the admin console. The URL is http: // localhost: 9990.

Deploy the application

We have prepared Application for hello world with JAX-RS, so please try clone at hand.

Deploy with wildfly-maven-plugin

Let's use wildfly-maven-plugin.

You can deploy with the following command:

mvn wildfly:deploy

The plugin settings are as follows.

<plugin>
    <groupId>org.wildfly.plugins</groupId>
    <artifactId>wildfly-maven-plugin</artifactId>
    <version>2.0.2.Final</version>
    <configuration>
        <hostname>localhost</hostname>
        <port>9990</port>
        <username>admin</username>
        <password>secret</password>
        <name>ROOT.war</name>
    </configuration>
</plugin>

By the way, using id seems to use the server authentication information written in Maven's settings.xml. In that case, username and password are not needed.

After deploying, check the operation with the following command.

curl http://localhost:8080/api/hello

After checking the operation, undeploy with the following command.

mvn wildfly:undeploy

Deploy with jboss-cli

Next, let's send the WAR file to the container and then deploy it with jboss-cli.

First, send the WAR file to the container with the following command (create the WAR file with mvn package).

docker cp target/demo-for-wildfly-0.1-SNAPSHOT.war demo:/tmp/

Then deploy with the following command:

docker exec demo /opt/jboss/wildfly/bin/jboss-cli.sh --connect \
 --command="deploy /tmp/demo-for-wildfly-0.1-SNAPSHOT.war --name=ROOT.war"

After deploying, check the operation with the following command.

curl http://localhost:8080/api/hello

This method also describes the undeploy command.

docker exec demo /opt/jboss/wildfly/bin/jboss-cli.sh --connect \
 --command="undeploy ROOT.war"

in conclusion

I was able to easily try WildFly using Docker (although it's easy enough because I just download it and run standalone.sh without using Docker).

that's all.

Recommended Posts

Try WildFly with Docker
Try running cloudera manager with docker
Try running Slack's (Classic) Bot with docker
Try using Kong + Konga with Docker Compose.
Try building Express + PostgreSQL + Sequelize with Docker [Part 2]
Try DI with Micronaut
Try running MPLS-VPN with FR Routing on Docker
Try create with Trailblazer
Rails deploy with Docker
Run Pico with docker
Try WebSocket with jooby
Explode Docker with WSL2
Use Puphpeteer with Docker
Try running OSPF with FR Routing on Docker
Operate Emby with Docker
Use ngrok with Docker
Run Payara with Docker
[Docker] Connection with MySQL
Php settings with Docker
Try building Express + PostgreSQL + Sequelize with Docker [Part 1]
Getting Started with Docker
Try using another Servlet container Jetty with Docker
Disposable PHP with Docker
Install Composer with Docker
Until you try running Apache Kafka with docker image
Feel free to try Elasticsearch cluster with WSL2 + Docker
Try connecting to AzureCosmosDB Emulator for Docker with Java
Run Mosquitto with Docker and try WebSocket communication with MQTT
Use GDAL with Python with Docker
Deploy with EC2 / Docker / Laravel
Run TAO Core with Docker
Try using GloVe with Deeplearning4j
Docker management with VS Code
Try using view_component with rails
Try Docker on Windows 10 Home
Set up GitLab with docker
Run Rails whenever with docker
Get started with DynamoDB with docker
Docker autostart settings with wsl2
[Docker] Rails 5.2 environment construction with docker
Spring Boot starting with Docker
Build docker environment with WSL
Version control CocoaPods with Docker
Web application built with docker (1)
Try reading XML with JDOM
I tried BIND with Docker
Added xa-data-source with WildFly 10 CLI
React environment construction with Docker
Build DynamoDB local with Docker
[Docker] Use whenever with Docker + Rails
People using docker Try using docker-compose
Using PlantUml with Honkit [Docker]
Rails + MySQL environment construction with Docker
Try Oracle Enterprise Manager Cloud Control with Docker Desktop for Windows
Node.js environment construction with Docker Compose
Run lambda with custom docker image
Deploy a Docker application with Greengrass
Build Couchbase local environment with Docker
Install java with Ubuntu 16.04 based Docker
Build a Node.js environment with Docker
Try AWS Lambda Runtime Interface Emulator with Docker Desktop for M1