WildFly Official Image is published on Docker Hub, so use it to try WildFly.
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
.
We have prepared Application for hello world with JAX-RS, so please try clone
at hand.
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
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"
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