Deploying a containerized Java web application

Install Docker CE

1) Set up the docker repository:

sudo apt-get update

sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

2) Install Docker CE

sudo apt-get update

sudo apt-get install docker-ce

3) Verify the installation

$ sudo docker run hello-world

Deployment with the jboss/wildfly Docker image

AdminFaces is an open source project which brings Bootstrap and AdminLTE to your application via a PrimeFaces theme and a JSF responsive template.

The sample files can be downloaded here

1) Create docker file Dockerfile with following content:

 FROM jboss/wildfly
 ADD admin-starter.war /opt/jboss/wildfly/standalone/deployments/

 

2) Place your admin-starter.war file in the same directory as your Dockerfile.

3) Run the build with:

sudo docker build --tag=admin-starter-app .

4) Run the container with:

sudo docker run -it -p 8080:8080 admin-starter-app

Application will be deployed on the container boot.

The application is available at http://localhost:8080/admin-starter

Pushing and Pulling to and from Docker Hub

1) Log into the Docker Hub from the command line

sudo docker login

2) Tag your image

sudo docker tag admin-starter-app yourhubusername/admin-starter-app:v0.0.1

3) Push your image to the repository you created

sudo docker push yourhubusername/admin-starter-app:v0.0.1

4) Create your Docker droplet

https://www.digitalocean.com/products/one-click-apps/docker/

5) Login in Digital Ocean

ssh user@yourDigitalOceanMachine

6) Allow Connections

sudo ufw allow 8080

7)  Pull your image

sudo docker pull yourhubusername/admin-starter-app:v0.0.1

8) Run the container with

sudo docker run -it -p 8080:8080 yourhubusername/admin-starter-app:v0.0.1

Application will be deployed on the container boot.

The application is available at http://yourDigitalOceanMachine:8080/admin-starter

 

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s