Docker Networking with Couchbase and WildFly

Docker Multi-Host networking allows you to create virtual networks and attach containers to them so you can create the network topology that is right for your application. This blog will show how to use it with Docker Compose.

CRUD Java Application with Couchbase, Java EE, and WildFly explained how to use a Java EE application to provide a CRUD/REST interface on a data bucket in Couchbase. It required to manually download and run WildFly. The blog also used Couchbase server using Docker and required manual configuration to load travel-sample bucket.

Configure Couchbase Docker Container using REST API explained how to use Couchbase REST API to configure Couchbase Server.

Docker Multi-Host Networking

This blog will remove the explicit download of WildFly and manual configuration of Couchbase server:

  • Use Docker Compose to start WildFly and Couchbase (no download required)
  • Use a Maven profile to configure Couchbase server (no manual configuration required)
  • Uses Docker multi-host networking so that WildFly and Couchbase server can talk to each other

Lets get started!

Start Couchbase and WildFly using Docker Multi-Host Networking and Compose

  1. Start WildFly and Couchbase server using docker-compose.yml file from
    arungupta/wildfly-admin image is used as it binds WildFly’s management to all network interfaces, and in addition also exposes port 9990. This enables WildFly Maven Plugin to be used to deploy the application.

    container_name is specified for Couchbase service and referred in WildFly service using COUCHBASE_URI. This is then used to connect to Couchbase from the Java EE application.

    The application environment is started as:

    --x-networking is an experimental switch added to Docker Compose 1.9 that allows to create a bridge or an overlay network. By default, it creates a bridge network that works on a single host. The network created can be seen as:

    Issue 2221 provide more explanation about the default networks created. wildflycouchbasejavaee7 is the new bridge network created for our application.  Issue #2345 provide some details about incorrect driver name in the output message.

Configure Couchbase Server

  1. Clone couchbase-javaee repo:

  2. Configure Couchbase server:

    exec-maven-plugin is used to invoke REST API and configure Couchbase server and is configured in a Maven profile. Make sure to setup property in pom.xml.

  3. Deploy the application to WildFly:

    Make sure to specify the correct host on CLI. In this case, this is the IP address obtained using docker-machine ip default.

Invoke the Application

  1. Invoke the REST endpoint using cURL:

    Complete set of REST endpoints are documented at CRUD Java Application with Couchbase, Java EE and WildFly. They are listed here for convenience:

    1. GET a single airline:
    2. Create a new airline using POST:

    3. Update an existing airline using PUT:
    4. Delete an existing airline using DELETE:


Be Sociable, Share!
  • Tweet

11 thoughts on “Docker Networking with Couchbase and WildFly

  1. Great post… thanks… Not to be nit-picky but the title is miss leading, Your example is not a multi-host example. In order for this example to be multi-host you would need to use the overlay driver and a key value store install for the docker engine. For example, you would need to do three things for this to work as a multi-host example.

    1) Implement a clustered or single node key value store (consul, etcd or zookeeper) that all Docker hosts (that need to see the network) can advertise to.

    2) Create the network using the “docker network create -d overlay” before doing the compose up command.

    3) add the net: in the compose yaml.

    John Willis

  2. John,

    Thanks for your comment, title updated.

    A true multi-host networking sample is that explains the steps clearly.

    Blog coming on that soon, stay tuned.


  3. Excellent example…. Most people don’t know that Swarm uses overlay by default with experimental. Great work…


  4. Pingback: Docker Bridge and Overlay Network with Compose Variable Substitution | Dinesh Ram Kali.
  5. Pingback: Docker Networking Design Philosophy | Docker Blog

Leave a Reply

Your email address will not be published. Required fields are marked *