Créer un site internet

Docker Compose

Docker compose:

  • Define and run multiple containers. 
  • The configuration can be defined in one or more files. The default name of the file is docker-compose.yml. Another file docker-compose-override.yml can override the default configuration in the docker-compose.yml


create the docker compose file.

$ sudo vi docker-compose.yml

The content of the docker-compose.yml

version: '3'
    image: jboss/wildfly
      - ~/deployments:/opt/jboss/wildfly/standalone/deployments
      - 8080:8080l

Note: make sure that the indentation of the file is respected.

Then run the commande

$ sudo docker-compose up -d
Creating network "helloweb_default" with the default driver
Creating helloweb_web_1 ... done

Display the list of the existing containers

$ sudo docker-compose ps
     Name                   Command               State           Ports         
helloweb_web_1   /opt/jboss/wildfly/bin/sta ...   Up>8080/tcp


Copy a web war to the deployment directory ~/deployments. Here is a link for an example of webapp.war

$ cp Downloads/docker-for-java-master/chapter2/webapp.war deployments/

The Rest resquest will display a list of persons

$curl http://localhost:8080/webapp/resources/persons

<!--?xml version="1.0" encoding="UTF-8" standalone="yes"?--><collection><person><name>Penny</name></person><person><name>Leonard</name></person><person><name>Sheldon</name></person><person><name>Amy</name></person><person><name>Howard</name></person><person><name>Bernadette</name></person><person><name>Raj</name></person><person><name>Priya</name></person></collection>

You can stop the container. This command should be run from the directory where the docker-compose file is created.

 $sudo docker-compose down
Stopping helloweb_web_1 ... done
Removing helloweb_web_1 ... done
Removing network helloweb_default/


  • rosario
    • 1. rosario On 22/12/2022
    Hello. I followed your tutorial. Wildfly works with the sample webapp. But how do I enable the management console? I tried to put port 9990 in the docker-compose file but I can't access the console. Where is it that I make a mistake? Thank you

Add a comment