Getting started with Docker and WildFly

This is the first of a set of tutorials about the Docker framework. In this one we will learn how to install the Docker platform on a Linux Centos machine and pull and execute a WildFly image on the top of it.

First of all, what is Docker ? Docker is a container-based software framework for automating deployment of applications. “Containers” are encapsulated, lightweight, and portable application modules. The major (intended) benefit of using a container is that your application will run consistently on and between any server, be it cloud or dedicated, or of varying operating systems.

Centos 6 or 7 ?

The Docker package is provided by default as part of CentOS-7. If you are running the CentOS 6.5 like me, you have to install the EPEL repository. You can find all details concerning the EPEL installation here: https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F

In my case I’ve installed the EPEL repository as follows:

rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Then, as a matter of best practice, we’ll update our packages:

yum update -y

Installing Docker

Done with EPEL, let’s install Docker by installing the docker-io package:

yum -y install docker-io

Once Docker is installed, you will need to start the docker daemon.

[jboss@localhost ~] $ sudo service docker start

Starting cgconfig service:                                 [  OK  ]

Starting docker:                                       [  OK  ]

Great! now your Docker is ready to rock!

Pulling Docker images

As next step, we will start pulling Docker images. The recommended repository for Docker images of WildFly is quay.io.

We will demonstrate how to install and run a wildfly vanilla Docker image. In order to do that issue the following command:

[jboss@localhost ~]$ docker pull quay.io/wildfly/wildfly-centos7

Once completed downloading the image, we will verify the available images in our Docker platform:

$ docker images | grep wildfly

quay.io/wildfly/wildfly-centos7             latest                        0ed0b7d75892        6 months ago        1.06 GB

In order to start the wildfly application server, simply issue:

[jboss@localhost ~]$ docker run -it quay.io/wildfly/wildfly-centos7
4:41:33,725 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
14:41:33,725 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
14:41:33,725 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 19.0.0.Final started in 5854ms - Started 391 of 576 services (324 services are lazy, passive or on-demand)

Seems the server started correclty. We can check it by issuing the docker ps command which retrieves the images process which are running and the ports engaged by the process:

[jboss@localhost ~]$ sudo docker ps

CONTAINER ID        IMAGE                  COMMAND                CREATED             STATUS              PORTS                NAMES

cac63ed21d67        quay.io/wildfly/wildfly-centos7   "/opt/jboss/wildfly/   3 minutes ago       Up 3 minutes        8080/tcp, 9990/tcp   happy_newton    

If you have notices the startup log of the server, you should have discovered that the server is located in the /opt/jboss/wildfly and that by default the public interfaces are bound to the 0.0.0.0 address whilst the admin interfaces are bound just to localhost. This information will be useful to learn how to customize the server.

So, in order to access to our wildfly server, we need to know which address has been chosen by the application server for socket binding. We will use the docker inspect command passing as parameter the ID of the Container we have already found (cac63ed21d67):

[jboss@localhost ~]$ sudo docker inspect -f ‘{{ .NetworkSettings.IPAddress }}’ cac63ed21d67

The above command will output:

172.17.0.11

So the server is available at the 172.17.0.11 IP Address. Now let’s open the console at that address: http://172.17.0.11:8080

wildfly docker tutorial wildfly docker tutorial

 

Et volià! WildFly served on a Docker image.

Continue reading in the next tutorial where we will learn how to customize the Docker image installation and deploy some applications on the top of it: Deploying applications on your Docker WildFly image