Now that you learned a lot about images, containers and how to link them together, it is about time to learn about the different deployment options. Let’s start over with the Ticket Monster applications again. Ticket Monster is a moderately complex application that demonstrates how to build modern applications using JBoss web technologies.
We’re going to build the application first.
-
Clone the repo:
$ cd /root
$ git clone https://github.com/jboss-developer/ticket-monster.git-
Build the application:
$ cd ticket-monster/demo
$ mvn clean packageCreate a folder to place the deployments and give it write access
$ mkdir /deployments
$ chmod 777 /deployments
$ chcon -Rt svirt_sandbox_file_t /deploymentsStart WildFly server as:
$ docker run --name wildfly -d -p 8080:8080 -v /deployments:/opt/jboss/wildfly/standalone/deployments/:rw jboss/wildflyThis command starts a container named “wildfly”.
The -v flag maps a directory from the host into the container. This will be the directory to put the deployments. rw ensures that the Docker container can write to it.
Check logs to verify if the server has started.
$ docker logs -f wildflyAccess http://<external-ip>:8080 in your browser to make sure the instance is up and running.
Now you’re ready to deploy the application for the first time.
Copy the geneated WAR to your deploy folder.
$ cp target/ticket-monster.war /deploymentsCongratulations!
You’ve deployed your first application to WildFly running in a Docker container from JBoss Developer Studio. You can check it by looking in the logs or accessing http://<external-ip>:8080/ticket-monster/
Stop WildFly container when you’re done.
$ docker stop wildfly $ docker rm wildfly
-
Download WildFly 10.0.0.Final from Internet: http://download.jboss.org/wildfly/10.0.0.Final/wildfly-10.0.0.Final.zip .
-
Install it by extracting the archive.
$ cd /root
$ wget http://download.jboss.org/wildfly/10.0.0.Final/wildfly-10.0.0.Final.zip
$ unzip wildfly-10.0.0.Final.zip
$ cd wildfly-10.0.0.Final/bin/The Command Line Interface (CLI) is a tool for connecting to WildFly instances to manage all tasks from command line environment. Some of the tasks that you can do using the CLI are:
-
Deploy/Undeploy web application in standalone/Domain Mode.
-
View all information about the deployed application on runtime.
-
Start/Stop/Restart Nodes in respective mode i.e. Standalone/Domain.
-
Adding/Deleting resource or subsystems to servers.
Lets use the CLI to deploy ticket-monster to WildFly running in the container.
-
CLI needs to be locally installed and comes as part of WildFly.
-
Run the “wildfly-management” image with fixed port mapping as explained in [Management_Fixed_Port_Mapping].
-
Run the
jboss-clicommand and connect to the WildFly instance.
Start WildFly server as:
$ docker run --name wildfly-managed -d -p 8080:8080 -p 9990:9990 rafabene/wildfly-adminThis command starts a container named “wildfly-managed”.
$ ./jboss-cli.sh --controller='localhost:9990' -u='admin' -p='docker#admin' -cThis will show the output as:
[standalone@localhost:9990 /]-
Deploy the application as:
deploy /root/ticket-monster/demo/target/ticket-monster.war --force
exit-
Stop Wildfly
$ docker stop wildfly-managed
$ docker rm wildfly-managedNow you’ve sucessfully used the CLI to remote deploy the Ticket Monster application to WildFly running as docker container.